import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Array as A
import Data.List (partition)

main :: IO ()
main = do
  (h : w : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  aijs <- map (map (== '#') . T.unpack) . T.lines <$> T.getContents :: IO [[Bool]]
  let
    ijs = map (flip map [1..w] . (,)) $ [1..h] :: [[(Int, Int)]]
    aijs' = A.array ((1, 1), (h, w)) . zip (concat ijs) . concat $ aijs
    (bijs', cijs') = partition snd . zip (concat ijs) . concat $ aijs
    bijs = map fst bijs'
    cijs = map fst cijs'
    -- m = maximum . (0 :) . map (\ij -> minimum . map (dist ij) $ bijs) $ cijs
    m = maximum . (0 : ) . map (\(i, j) -> until (\r -> any . map (aijs' A.!) $ [(i + d, j + r - d) | d <- [1..r]] ++ [(i - d, j + d - r) | d <- [1..r]] ++ [(i - r + d, j + d) | d <- [1..r]] ++ [(i + r - d, j - d) | d <- [1..r]]) succ 1) $ cijs
  print m

dist :: (Int, Int) -> (Int, Int) -> Int
dist (i, j) (k, l) = abs (k - i) + abs (l - j)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
