import numpy as np



H,W = list(map(int,input().split()))

# 周りに壁を、0,1化、壁を0で持つ

grid = np.zeros((H+2,W+2),dtype=np.bool)

grid[1:-1,1:-1] = (np.array([list(eval(input())) for _ in range(H)]) == '.')



L = grid.size



# x軸方向の集計

def F(transpose):

  x = grid

  if transpose:

    x = x.T

  x = np.ravel(x) # to 1D array

  

  left_zero = -np.arange(L) # 左の壁のindexの-1倍

  left_zero[x] = 0

  np.minimum.accumulate(left_zero, out=left_zero)

  

  right_zero = np.arange(L) # 逆順ソートした上で左の壁のindex

  right_zero[x[::-1]] = 0

  np.maximum.accumulate(right_zero, out=right_zero)

  

  y = left_zero

  y -= right_zero[::-1]

  

  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)

  

answer = (F(False) + F(True)).max()+2*L-5

print(answer)

import numpy as np

import sys

buf = sys.stdin.buffer



H,W = list(map(int,buf.readline().split()))

# 周りに壁を、0,1化、壁を0で持つ

grid = np.zeros((H+2,W+2),dtype=np.bool)

grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1))



# x軸方向の集計

def F(transpose):

  x = grid

  if transpose:

    x = (x.T).copy()

  x = np.ravel(x) # to 1D array

  L = len(x)

  

  left_zero = -np.arange(L) # 左の壁のindexの-1倍

  left_zero[x] = 0

  np.minimum.accumulate(left_zero, out=left_zero)

  

  right_zero = np.arange(L) # 逆順ソートした上で左の壁のindex

  right_zero[x[::-1]] = 0

  np.maximum.accumulate(right_zero, out=right_zero)

  

  y = left_zero

  y += L-right_zero[::-1]

  

  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)

  

answer = (F(False) + F(True)).max()-5

print(answer)

import numpy as np

H, W = list(map(int, input().split()))
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H + 2, W + 2), dtype=np.bool)
grid[1:-1, 1:-1] = np.array([list(eval(input())) for _ in range(H)]) == "."
L = grid.size
# x軸方向の集計
def F(transpose):
    x = grid
    if transpose:
        x = x.T
    x = np.ravel(x)  # to 1D array
    left_zero = -np.arange(L)  # 左の壁のindexの-1倍
    left_zero[x] = 0
    np.minimum.accumulate(left_zero, out=left_zero)
    right_zero = np.arange(L)  # 逆順ソートした上で左の壁のindex
    right_zero[x[::-1]] = 0
    np.maximum.accumulate(right_zero, out=right_zero)
    y = left_zero
    y -= right_zero[::-1]
    return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)


answer = (F(False) + F(True)).max() + 2 * L - 5
print(answer)

import numpy as np
import sys

buf = sys.stdin.buffer
H, W = list(map(int, buf.readline().split()))
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H + 2, W + 2), dtype=np.bool)
grid[1:-1, 1:] = (np.frombuffer(buf.read(H * (W + 1)), dtype="S1") == b".").reshape(
    (H, W + 1)
)
# x軸方向の集計
def F(transpose):
    x = grid
    if transpose:
        x = (x.T).copy()
    x = np.ravel(x)  # to 1D array
    L = len(x)
    left_zero = -np.arange(L)  # 左の壁のindexの-1倍
    left_zero[x] = 0
    np.minimum.accumulate(left_zero, out=left_zero)
    right_zero = np.arange(L)  # 逆順ソートした上で左の壁のindex
    right_zero[x[::-1]] = 0
    np.maximum.accumulate(right_zero, out=right_zero)
    y = left_zero
    y += L - right_zero[::-1]
    return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)


answer = (F(False) + F(True)).max() - 5
print(answer)

+import sys -H, W = list(map(int, input().split())) +buf = sys.stdin.buffer +H, W = list(map(int, buf.readline().split())) -grid[1:-1, 1:-1] = np.array([list(eval(input())) for _ in range(H)]) == "." -L = grid.size +grid[1:-1, 1:] = (np.frombuffer(buf.read(H * (W + 1)), dtype="S1") == b".").reshape( +    (H, W + 1) +) -        x = x.T +        x = (x.T).copy() +    L = len(x) -    y -= right_zero[::-1] +    y += L - right_zero[::-1] -answer = (F(False) + F(True)).max() + 2 * L - 5 +answer = (F(False) + F(True)).max() - 5