import numpy as np



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

temp = np.array([list(eval(input())) for _ in range(H)])

# 周りに壁を、0,1化

map = np.zeros((H+2,W+2),dtype=np.int32)

map[1:-1,1:-1][temp == '.'] = 1



# x軸正方向の集計

def F(transpose,reverse):

  x = map.copy()

  if transpose:

    x = x.T

  x = np.ravel(x)

  if reverse:

    x = x[::-1]

  zero_idx = np.nonzero(x==0)[0]

  x[zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形

  x = x.cumsum()

  if reverse:

    x = x[::-1]

  if transpose:

    x = x.reshape(map.T.shape).T

  else:

    x = x.reshape(map.shape)

  return x



answer = np.zeros_like(map)

for t in [True,False]:

  for r in [True,False]:

    answer += F(t,r)

    

answer = answer.max() - 3

print(answer)
import numpy as np



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

temp = np.array([list(eval(input())) for _ in range(H)])

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

map = np.ones((H+2,W+2),dtype=np.bool)

map[1:-1,1:-1] = (temp == '#')



# x軸正方向の集計

def F(transpose):

  x = map.copy()

  if transpose:

    x = x.T

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

  

  zero_idx = np.nonzero(x)[0]

  zero_span = np.diff(zero_idx) - 1 # 次の0までにある1の個数

  y = np.zeros(len(x),dtype=np.int32)

  y[1:][zero_idx[:-1]] = zero_span

  y[zero_idx[1:]] -= zero_span

  y = y.cumsum()

  if transpose:

    y = y.reshape(map.T.shape).T

  else:

    y = y.reshape(map.shape)

  return y



answer = np.zeros(map.shape,dtype=np.int32)

for t in [True,False]:

  answer += F(t)

    

answer = answer.max() - 1

print(answer)
import numpy as np

H, W = list(map(int, input().split()))
temp = np.array([list(eval(input())) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H + 2, W + 2), dtype=np.int32)
map[1:-1, 1:-1][temp == "."] = 1
# x軸正方向の集計
def F(transpose, reverse):
    x = map.copy()
    if transpose:
        x = x.T
    x = np.ravel(x)
    if reverse:
        x = x[::-1]
    zero_idx = np.nonzero(x == 0)[0]
    x[zero_idx[1:]] = 1 - np.diff(zero_idx)  # cumsumで求められるように変形
    x = x.cumsum()
    if reverse:
        x = x[::-1]
    if transpose:
        x = x.reshape(map.T.shape).T
    else:
        x = x.reshape(map.shape)
    return x


answer = np.zeros_like(map)
for t in [True, False]:
    for r in [True, False]:
        answer += F(t, r)
answer = answer.max() - 3
print(answer)

import numpy as np

H, W = list(map(int, input().split()))
temp = np.array([list(eval(input())) for _ in range(H)])
# 周りに壁を、0,1化、壁をTrueで持つ
map = np.ones((H + 2, W + 2), dtype=np.bool)
map[1:-1, 1:-1] = temp == "#"
# x軸正方向の集計
def F(transpose):
    x = map.copy()
    if transpose:
        x = x.T
    x = np.ravel(x)  # to 1D array
    zero_idx = np.nonzero(x)[0]
    zero_span = np.diff(zero_idx) - 1  # 次の0までにある1の個数
    y = np.zeros(len(x), dtype=np.int32)
    y[1:][zero_idx[:-1]] = zero_span
    y[zero_idx[1:]] -= zero_span
    y = y.cumsum()
    if transpose:
        y = y.reshape(map.T.shape).T
    else:
        y = y.reshape(map.shape)
    return y


answer = np.zeros(map.shape, dtype=np.int32)
for t in [True, False]:
    answer += F(t)
answer = answer.max() - 1
print(answer)

-# 周りに壁を、0,1化 -map = np.zeros((H + 2, W + 2), dtype=np.int32) -map[1:-1, 1:-1][temp == "."] = 1 +# 周りに壁を、0,1化、壁をTrueで持つ +map = np.ones((H + 2, W + 2), dtype=np.bool) +map[1:-1, 1:-1] = temp == "#" -def F(transpose, reverse): +def F(transpose): -    x = np.ravel(x) -    if reverse: -        x = x[::-1] -    zero_idx = np.nonzero(x == 0)[0] -    x[zero_idx[1:]] = 1 - np.diff(zero_idx)  # cumsumで求められるように変形 -    x = x.cumsum() -    if reverse: -        x = x[::-1] +    x = np.ravel(x)  # to 1D array +    zero_idx = np.nonzero(x)[0] +    zero_span = np.diff(zero_idx) - 1  # 次の0までにある1の個数 +    y = np.zeros(len(x), dtype=np.int32) +    y[1:][zero_idx[:-1]] = zero_span +    y[zero_idx[1:]] -= zero_span +    y = y.cumsum() -        x = x.reshape(map.T.shape).T +        y = y.reshape(map.T.shape).T -        x = x.reshape(map.shape) -    return x +        y = y.reshape(map.shape) +    return y -answer = np.zeros_like(map) +answer = np.zeros(map.shape, dtype=np.int32) -    for r in [True, False]: -        answer += F(t, r) -answer = answer.max() - 3 +    answer += F(t) +answer = answer.max() - 1