H, W = map(int, input().split()) curr = [0] * (W + 2) maxLen = 0 for r in range(H): s = input() prev, curr = curr, [0] * (W + 2) for c in range(1, W + 1): if s[c - 1] == "#": curr[c] = min(prev[c - 1], prev[c], curr[c - 1]) + 1 maxLen = max(maxLen, curr[c]) print((maxLen + 1) // 2)