h, w = gets.split().map(&:to_i)
a = Array.new(h)
black_index = Array.new()
h.times do |i|
  a[i] = gets.chomp.split("")
  sharp_index = a[i].map.with_index{ |e,i| e == "#" ? i : nil }.compact
  sharp_index.each do |j|
    black_index.push([i, j])
  end
end

count = 0
while true do
  tmp_black_index = Array.new()
  tmp_a = Marshal.load(Marshal.dump(a))
  black_index.each do |i|
    if i[0] != 0
      a[i[0]-1][i[1]] = "#"
      tmp_black_index.push([i[0]-1, i[1]])
    end
    if i[1] != w - 1
      a[i[0]][i[1]+1] = "#"
      tmp_black_index.push([i[0], i[1]+1])
    end
    if i[0] != h - 1
      a[i[0]+1][i[1]] = "#"
      tmp_black_index.push([i[0]+1, i[1]])
    end
    if i[1] != 0
      a[i[0]][i[1]-1] = "#"
      tmp_black_index.push([i[0], i[1]-1])
    end
  end
  if tmp_a == a
    break
  else
    count += 1
    black_index = Marshal.load(Marshal.dump(tmp_black_index))
  end
end
    
puts count