# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

H,W = map(int,input().split())
S = [list(input())[:-1] for _ in range(H)]
for i in range(H):
    for j in range(W):
        S[i][j] = int(S[i][j]=='#')

dp = [S[i][:] for i in range(H)]
for i in range(1,H):
    for j in range(1,W):
        if S[i][j]==1:
            dp[i][j] = min(dp[i][j-1],dp[i-1][j],dp[i-1][j-1])+1

print((max(max(dp[i]) for i in range(H))+1)//2)