H, W = gets.split(' ').map(&:to_i)

memo = Array.new(H){Array.new(W, -1)}
queue = Array.new
H.times do |i|
  line = gets.chomp
  line.size.times do |j|
    if line[j] == '#'
      memo[i][j] = 0
      queue.push([i, j, 0])
    end
  end
end

maxval = 0
lrud = [[0, -1], [0, 1], [-1, 0], [1, 0]]
while !(queue.empty?)
  nowx, nowy, step = queue.shift
  lrud.each do |move|
    x, y = nowx + move[0], nowy + move[1]
    next if x < 0 || x >= H || y < 0 || y >= W
    if memo[x][y] == -1
      memo[x][y] = step + 1
      maxval = step + 1
      queue.push([x, y, step + 1])
    end
  end
end

puts maxval