def main(): import sys input = sys.stdin.readline class cs_2d(): def __init__(self,x): n = len(x) m = len(x[0]) tmp = [[0]*(m+1) for _ in range(n+1)] for i in range(n): tmp[i+1][1:] = x[i] for j in range(m): tmp[i+1][j+1] += tmp[i+1][j] for j in range(m): for i in range(n): tmp[i+1][j+1] += tmp[i][j+1] self.S = tmp def query(self,ix,jx,iy,jy): ##[ix,jx)×[iy,jy) T = self.S return T[jx][jy] - T[jx][iy] - T[ix][jy] + T[ix][iy] H,W = map(int,input().split()) S = [list(map(lambda x : x == '.',input()))[:-1] for _ in range(H)] C = cs_2d(S) def is_ok(x,y,n): return C.query(x-n+1,x+n,y-n+1,y+n)==0 ans = 1 for i in range(1,H-1): for j in range(ans,W-ans): if S[i][j] == 1: continue L = min(i+1,j+1,H-i,W-j) if L 1: mid = (y+x)//2 if is_ok(i,j,mid): x = mid else: y = mid ans = x print(ans) main()