H, W = gets.chomp.split(' ').map(&:to_i)
map = []
blacks = []
H.times do |h|
  map.push(gets.chomp.split('').map.with_index do |c, w|
    if c == '#'
      blacks.push [h,w]
    end
    c == '#'
  end)
end
result = 0
H.times do |h|
  W.times do |w|
    next if map[h][w]
    dis = H + W
    blacks.each do |th, tw|
      _dis = (th - h).abs + (tw -w).abs
      dis = _dis if dis > _dis
    end
    result = dis if result < dis
  end
end
puts result