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 JavaScript (node.js v5.12) (judge verdict: Accepted)

module.exports=function(r){var t={};function e(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return r[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var i in r)e.d(n,i,function(t){return r[t]}.bind(null,i));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=0)}([function(r,t,e){"use strict";var n=e(1),i=new(e(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));e(4)(i)},function(r,t){r.exports=require("fs")},function(r,t,e){"use strict";var n=e(3);r.exports=class{constructor(r){this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}add(r){this.inp.enq(r)}}},function(r,t,e){"use strict";r.exports=class{constructor(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=r.length,this.items=r,this.ind=0}enq(r){this.size+=1,this.items.push(r)}deq(){var r=this.items[this.ind];return this.size-=1,this.ind+=1,r}}},function(r,t,e){"use strict";r.exports=function(r){for(var t=r.in(),e=r.in(),n=new Array(t),i=new Array(t),o=0;o<t;o++){var u=r.inr();n[o]=u,i[o]=new Array(e);for(var s=0;s<e;s++)i[o][s]={l:0,r:0,u:0,d:0},"#"!=n[o][s]&&(s>0&&(i[o][s].l=i[o][s-1].l),o>0&&(i[o][s].u=i[o-1][s].u),i[o][s].l++,i[o][s].u++)}for(var c=0,f=t-1;f>=0;f--)for(var l=e-1;l>=0;l--)if("#"!=n[f][l]){l<e-1&&(i[f][l].r=i[f][l+1].r),f<t-1&&(i[f][l].d=i[f+1][l].d),i[f][l].r++,i[f][l].d++;var a=i[f][l].l+i[f][l].r+i[f][l].u+i[f][l].d-3;c<a&&(c=a)}console.log(c)}}]);