Problem:
Score : 400 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.

Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.
The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.
In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.

Snuke wants to maximize the number of squares lighted by the lamp.

You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.

Find the maximum possible number of squares lighted by the lamp.

Constraints

1 \leq H \leq 2,000

1 \leq W \leq 2,000

S_i is a string of length W consisting of # and ..

. occurs at least once in one of the strings S_i (1 \leq i \leq H).

Input

Input is given from Standard Input in the following format:

H W
S_1
:
S_H

Output

Print the maximum possible number of squares lighted by the lamp.

Sample Input 1

4 6
#..#..
.....#
....#.
#.#...

Sample Output 1

8

If Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.

Sample Input 2

8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#

Sample Output 2

13

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[100001];
int n, m;

int compare(const void *a, const void *b) {
	int an = *(int*)(a);
	int bn = *(int*)(b);
	if (an < bn) {
		return -1;
	}
	else if (an > bn) {
		return 1;

	}
	else {
		return 0;
	}
}

int inarray(int x) {
	void* ans = NULL;
	ans = bsearch(&x, a, m, sizeof(int), compare);
	if (ans != NULL) {
		return 1;
	}
	else {
		return 0;
	}
}

int main(void) {
	/*int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	int a, b, c;
	a = p + q;
	b = q + r;
	c = r + p;
	printf("%d\n", MIN(a, MIN(b, c)));*/
	/*
	int n;
	int w[101];
	scanf("%d", &n);
	scanf("%d", &w[0]);
	int first = w[0];
	int last = 0;
	for (int i = 1; i < n; i++) {
		scanf("%d", &w[i]);
		last += w[i];
	}

	int min = abs(first - last);
	for (int i = 1; i < n-1; i++) {
		first += w[i];
		last -= w[i];
		int temp = abs(first - last);
		if (min > temp) {
			min = temp;
		}
	}
	printf("%d\n", min);*/
	/*
	scanf("%d %d", &n, &m);
	long long int dp[100001];
	for (int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	if (inarray(0)) {
		dp[0] = 0;
	}
	else {
		dp[0] = 1;
	}
	if (inarray(1)) {
		dp[1] = 0;
	}
	else {
		dp[1] = 1 + dp[0];
	}
	for (int i = 2; i < n; i++) {
		if (inarray(i)) {
			dp[i] = 0;
		}
		else {
			dp[i] = (dp[i - 1] + dp[i - 2])%1000000007;
		}
	}
	printf("%lld\n", dp[n - 1]);*/

	int H, W;
	scanf("%d %d", &H, &W);
	char s[2001][2001];
	for (int i = 0; i < H; i++) {
		scanf("%s", s[i]);
	}
	int vertical[2001] = { 0 };
	int horizontal[2001] = { 0 };
	
	//int v_count[2001] = { 0 };
	//int h_count[2001] = { 0 };

	int max = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				//v_count[j] = 0;
				//h_count[i] = 0;
				vertical[j] = 0;
				horizontal[i] = 0;
			}
			else {
				if (vertical[j] == 0) {
					vertical[j]++;
					while (i+vertical[j]<H) {
						if (s[i + vertical[j]][j] == '#') {
							break;
						}
						else {
							vertical[j]++;
						}
					}
				}
				if (horizontal[i] == 0) {
					horizontal[i]++;
					while (j + horizontal[i] < W) {
						if (s[i][j + horizontal[i]] == '#') {
							break;
						}
						else {
							horizontal[i]++;
						}
					}
				}
				if (max < horizontal[i] + vertical[j] - 1) {
					max = horizontal[i] + vertical[j] - 1;
				}
			}
		}
	}
	printf("%d\n", max);

	return 0;
}