from collections import deque import sys input = sys.stdin.readline H,W=map(int,input().split()) MAP=[input() for i in range(H)] ANS=[[1<<30]*(W+2) for i in range(H+2)] Q=deque() for i in range(H+2): ANS[i][0]=0 ANS[i][W+1]=0 Q.append((i,0)) Q.append((i,W+1)) for i in range(W+2): ANS[0][i]=0 ANS[H+1][i]=0 Q.append((0,i)) Q.append((H+1,i)) for i in range(H): for j in range(W): if MAP[i][j]==".": Q.append((i+1,j+1)) ANS[i+1][j+1]=0 while Q: x,y=Q.popleft() for z in [x-1,x,x+1]: for w in [y-1,y,y+1]: if 0<=zANS[x][y]+1: ANS[z][w]=ANS[x][y]+1 Q.append((z,w)) MAX=0 for ans in ANS: MAX=max(MAX,max(ans)) #print(*ans) print(MAX)