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():

  x = map.copy()

  for row in range(1,H+1):

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

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

  x = x.cumsum(axis = 1)

  return x



# y軸

def G():

  x = map.T.copy()

  for row in range(1,W+1):

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

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

  x = x.cumsum(axis = 1)

  return x.T



answer = np.zeros_like(map)

# x軸

answer += F()

# 逆順

map = map[:,::-1]

answer += F()[:,::-1]

map = map[:,::-1]



# y軸

answer += G()

# 逆順

map = map[::-1,:]

answer += G()[::-1,:]



answer = np.max(answer) - 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化

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化
map = np.zeros((H + 2, W + 2), dtype=np.int32)
map[1:-1, 1:-1][temp == "."] = 1
# x軸正方向の集計
def F():
    x = map.copy()
    for row in range(1, H + 1):
        zero_idx = np.nonzero(x[row] == 0)[0]
        x[row, zero_idx[1:]] = 1 - np.diff(zero_idx)  # cumsumで求められるように変形
    x = x.cumsum(axis=1)
    return x


# y軸
def G():
    x = map.T.copy()
    for row in range(1, W + 1):
        zero_idx = np.nonzero(x[row] == 0)[0]
        x[row, zero_idx[1:]] = 1 - np.diff(zero_idx)  # cumsumで求められるように変形
    x = x.cumsum(axis=1)
    return x.T


answer = np.zeros_like(map)
# x軸
answer += F()
# 逆順
map = map[:, ::-1]
answer += F()[:, ::-1]
map = map[:, ::-1]
# y軸
answer += G()
# 逆順
map = map[::-1, :]
answer += G()[::-1, :]
answer = np.max(answer) - 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化
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)

-def F(): +def F(transpose, reverse): -    for row in range(1, H + 1): -        zero_idx = np.nonzero(x[row] == 0)[0] -        x[row, zero_idx[1:]] = 1 - np.diff(zero_idx)  # cumsumで求められるように変形 -    x = x.cumsum(axis=1) +    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) -# y軸 -def G(): -    x = map.T.copy() -    for row in range(1, W + 1): -        zero_idx = np.nonzero(x[row] == 0)[0] -        x[row, zero_idx[1:]] = 1 - np.diff(zero_idx)  # cumsumで求められるように変形 -    x = x.cumsum(axis=1) -    return x.T - - -# x軸 -answer += F() -# 逆順 -map = map[:, ::-1] -answer += F()[:, ::-1] -map = map[:, ::-1] -# y軸 -answer += G() -# 逆順 -map = map[::-1, :] -answer += G()[::-1, :] -answer = np.max(answer) - 3 +for t in [True, False]: +    for r in [True, False]: +        answer += F(t, r) +answer = answer.max() - 3