import qualified Data.Map.Strict as M
import Data.List
import Data.Maybe

main = interact $ unlines . unfoldr main' . lines
 where
  main' (n':xs)
   | n' == "0" = Nothing
   | otherwise = return (show (square_searching m), xs')
   where
    (m',xs') = splitAt n xs
    n = read n'
    m = [(y,x) | y<-[0..n-1], x<-[0..n-1], m'!!y!!x == '.']

square_searching :: [(Int,Int)] -> Int
square_searching m
 | null m = 0
 | otherwise = maximum $ M.elems (foldl' dp M.empty m)

dp :: M.Map (Int,Int) Int -> (Int,Int) -> M.Map (Int,Int) Int
dp m yx@(y,x) = M.insert yx (v+1) (M.filterWithKey (\(y',_) _ -> y'>=y-2) m)
 where v = minimum $ map (\k -> M.findWithDefault 0 k m) [(y-1,x),(y,x-1),(y-1,x-1)]