h, w = gets.split.map(&:to_i)

visit = Array.new(h) {Array.new(w, false)}
que = []
h.times do |i|
    gets.each_char.with_index do |c, j|
        if c == "#"
            que << [i, j] 
            visit[i][j] = 0
        end
    end
end

ans = 0
while ij = que.shift
    i, j = ij

    if i > 0 && !visit[i - 1][j]
        que << [i - 1, j]
        ans = visit[i - 1][j] = visit[i][j] + 1
    end

    if i < h - 1 && !visit[i + 1][j]
        que << [i + 1, j]
        ans = visit[i + 1][j] = visit[i][j] + 1
    end

    if j > 0 && !visit[i][j - 1]
        que << [i, j - 1]
        ans = visit[i][j - 1] = visit[i][j] + 1
    end

    if j < w - 1 && !visit[i][j + 1]
        que << [i, j + 1]
        ans = visit[i][j + 1] = visit[i][j] + 1
    end
end

puts ans