#!/bin/python3

import collections

nr, nc = map(int, input().split())

g = ["-"*(nc+2)] + ["-"+input()+"-" for _ in range(nr)] + ["-"*(nc+2)]

q = collections.deque()

q = collections.deque((r,c) for r in range(nr+2) for c in range(nc+2) if g[r][c] == '-')
dist = [[-1 for _ in range(nc+2)] for _ in range(nr+2)] ;
for (r,c) in q:
   dist[r][c] = 0

vv = 0
while q:
    r, c = q[0]
    q.popleft()
    for dr, dc in [(-1,0), (1,0), (0,-1), (0,1)]:
        rr, cc = r+dr, c+dc
        if rr >= 0 and rr <= nr + 1 and cc >= 0 and cc <= nc + 1 and dist[rr][cc] < 0:
            dist[rr][cc] = dist[r][c] + 1
            vv = dist[rr][cc]
            q.append((rr,cc))

print(vv)
