h, w = gets.chomp.split(" ").map(&:to_i)
a = ""
h.times { a.concat(gets.chomp) }

queue = []
idx = 0
turn = Hash.new(0)
while (idx = a.index("#", idx))
  queue << idx
  turn[idx] = 1
  idx += 1
end

cnt = 0
max_cnt = 0
while (q = queue.shift)
  cnt = turn[q]
  max_cnt = cnt if cnt > max_cnt
  i, j = q.divmod(w)
  if i > 0 && turn[(idx = (i - 1) * w + j)].zero?
    queue << idx
    turn[idx] = cnt + 1
  end
  if i < h - 1 && turn[(idx = (i + 1) * w + j)].zero?
    queue << idx
    turn[idx] = cnt + 1
  end
  if j > 0 && turn[(idx = i * w + (j - 1))].zero?
    queue << idx
    turn[idx] = cnt + 1
  end
  if j < w - 1 && turn[(idx = i * w + (j + 1))].zero?
    queue << idx
    turn[idx] = cnt + 1
  end
end

puts max_cnt - 1