import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {


  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.fill(h){readLine.trim.toCharArray.map(_ == '#')}
  val memo = Array.fill(h){Array.fill(w){-1}}
  val queue = mutable.Queue[Point]()
  for (p ← (0 until h).flatMap{y ⇒ (0 until w).filter{x ⇒ state(y)(x)}.map{x ⇒ Point(x, y)}}) {
    queue.enqueue(p)
    memo(p.y)(p.x) = 0
  }
  while(queue.nonEmpty) {
    val current = queue.dequeue()
    for (next ← current.neighbors if (0 until h).contains(next.y) && (0 until w).contains(next.x) && !state(next.y)(next.x)) if (!state(next.y)(next.x)) {
      memo(next.y)(next.x) = memo(current.y)(current.x) + 1
      state(next.y)(next.x) = true
      queue.enqueue(next)
    }
  }
  println(memo.map{_.max}.max)

  case class Point(x: Int, y: Int){
    def neighbors = List(Point(x + 1, y), Point(x - 1, y), Point(x, y + 1), Point(x, y - 1))
  }
}