H, W = gets.chomp.split(' ').map(&:to_i)
map = Array.new(H)
blacks = []
H.times do |h|
  map[h] = Array.new(W,0)
  str = gets.chomp!
  index = 0
  while(index = str.index('#', index)) do
    map[h][index] = 1
    blacks.push([h, index])
    index += 1
  end
end
result = 0
while(q = blacks.shift) do
  h, w = q
  [[0,1],[0,-1],[1,0],[-1,0]].each do |dh,dw|
    next if h+dh < 0 || h+dh >= H || w+dw < 0 || w+dw >= W
    next if map[h+dh][w+dw] > 0
    map[h+dh][w+dw] = map[h][w] + 1
    blacks.push [h+dh, w+dw]
    result = [result, map[h+dh][w+dw]].max
  end
end
puts (result - 1)