import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(h, w) = in.readLine().split(' ').map(_.toInt)
  val field = Array.fill(h)(in.readLine().toCharArray)
  val queue = new java.util.ArrayDeque[((Int, Int), Int)]()
  for (j <- 0 until h; i <- 0 until w; if field(j)(i) == '#') queue.offer(((i, j), 0))
  var times = 0
  while(!queue.isEmpty) {
    val ((x, y), count) = queue.poll()
    for {
      p <- Seq((x,y-1), (x,y+1), (x-1,y), (x+1,y))
      if p._1 >= 0 && p._1 < w && p._2 >= 0 && p._2 < h
      if field(p._2)(p._1) == '.'
    } {
      field(p._2)(p._1) = '#'
      queue.offer((p, count+1))
    }
    if (times < count) times = count
  }
  println(times)
}