h, w = gets.chomp.split(" ").map{|x| x.to_i}
b = readlines

black = []
hh = 1
b.each{|line|
  data = line.chomp.split("")
  ww = 1
  data.each{|x|
    if x == "#"
      black.push([hh, ww])
    end
    ww += 1
    }
  hh += 1
  }

max = 0
for i in 1..h do
  for j in 1..w do
    min = h+w
    black.each{|a|
      t = (i-a[0]).abs + (j-a[1]).abs
      if min > t
        min = t
      end
      }
    if max < min
      max = min
    end
  end
end

puts max