## code borrowed from "maspy"

import numpy as np
import sys
buf = sys.stdin.buffer
 
H,W = 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.where(x,0,-np.arange(L)) # 左の壁のindexの-1倍
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.where(x[::-1],0,np.arange(L)) # 逆順ソートした上で左の壁のindex
  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 numpy import sys sys buf = sys.stdin.buffer buf sys.stdin.buffer sys.stdin sys stdin buffer H,W = map(int,buf.readline().split()) H map(int,buf.readline().split()) map int buf.readline().split() buf.readline().split buf.readline() buf.readline buf readline split W grid = np.zeros((H+2,W+2),dtype=np.bool) grid np.zeros((H+2,W+2),dtype=np.bool) np.zeros np zeros (H+2,W+2) H+2 H 2 W+2 W 2 dtype=np.bool dtype np.bool np bool grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1)) grid[1:-1,1:] grid 1:-1 1 -1 (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1)) np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.' np.frombuffer(buf.read(H*(W+1)),dtype='S1') np.frombuffer np frombuffer buf.read(H*(W+1)) buf.read buf read H*(W+1) H W+1 W 1 dtype='S1' dtype 'S1' b'.' reshape (H,W+1) H W+1 W 1 def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = np.where(x,0,-np.arange(L)) # 左の壁のindexの-1倍
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.where(x[::-1],0,np.arange(L)) # 逆順ソートした上で左の壁のindex
  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)
   F x = grid x grid if transpose:
    x = (x.T).copy()
   transpose x = (x.T).copy() x (x.T).copy() x.T).copy x.T x T copy x = np.ravel(x) x np.ravel(x) np.ravel np ravel x L = len(x) L len(x) len x left_zero = np.where(x,0,-np.arange(L)) left_zero np.where(x,0,-np.arange(L)) np.where np where x 0 -np.arange(L) np.arange(L) np.arange np arange L np.minimum.accumulate(left_zero, out=left_zero) np.minimum.accumulate np.minimum np minimum accumulate left_zero out=left_zero out left_zero right_zero = np.where(x[::-1],0,np.arange(L)) right_zero np.where(x[::-1],0,np.arange(L)) np.where np where x[::-1] x ::-1 -1 0 np.arange(L) np.arange np arange L np.maximum.accumulate(right_zero, out=right_zero) np.maximum.accumulate np.maximum np maximum accumulate right_zero out=right_zero out right_zero y = left_zero y left_zero y += L-right_zero[::-1] y L-right_zero[::-1] L right_zero[::-1] right_zero ::-1 -1 return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape) y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape) transpose y.reshape(grid.T.shape).T y.reshape(grid.T.shape) y.reshape y reshape grid.T.shape grid.T grid T shape T y.reshape(grid.shape) y.reshape y reshape grid.shape grid shape transpose transpose answer = (F(False) + F(True)).max()-5 answer (F(False) + F(True)).max()-5 (F(False) + F(True)).max() F(False) + F(True)).max F(False) + F(True) F(False) F False F(True) F True max 5 print(answer) print answer grid = np.zeros((H+2,W+2),dtype=np.bool) np.zeros((H+2,W+2),dtype=np.bool) grid H,W = map(int,buf.readline().split()) map(int,buf.readline().split()) H def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = np.where(x,0,-np.arange(L)) # 左の壁のindexの-1倍
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.where(x[::-1],0,np.arange(L)) # 逆順ソートした上で左の壁のindex
  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)
   def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = np.where(x,0,-np.arange(L)) # 左の壁のindexの-1倍
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.where(x[::-1],0,np.arange(L)) # 逆順ソートした上で左の壁のindex
  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)
   F buf = sys.stdin.buffer sys.stdin.buffer buf answer = (F(False) + F(True)).max()-5 (F(False) + F(True)).max()-5 answer W = map(int,buf.readline().split()) map(int,buf.readline().split()) W
## code borrowed from "maspy"

import numpy as np
import sys
buf = sys.stdin.buffer
 
H,W = 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.where(x,0,-np.arange(L)) # 左の壁のindexの-1倍
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.where(x[::-1],0,np.arange(L)) # 逆順ソートした上で左の壁のindex
  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)