H, W = gets.chomp.split(' ').map(&:to_i)
map = []
blacks = []
H.times do |h|
  map.push(gets.chomp.split('').map.with_index do |c, w|
    if c == '#'
      blacks.push [h,w]
    end
    c == '#' ? 1 : 0
  end)
end
result = 0
while(h, w = blacks.shift)
  [[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)