import Data.List
import Control.Monad
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad.ST
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B

--import Debug.Trace

type Field s = STUArray s (Int,Int) Int

modifyArray :: (MArray a e m ,Ix i) => a i e -> i -> (e -> e) -> m ()
modifyArray arr i f =  readArray arr i >>= writeArray arr i . f

f :: Field s -> Int -> [[Char]] -> ST s ()
f arr' y [] = return ()
f arr' y (s:field) = do
  sub arr' 1 $ group s
  f arr' (y+1) field
  where
    sub :: Field s -> Int -> [[Char]] -> ST s ()
    sub arr i [] = return ()
    sub arr i (a:bs) = if head a == '.' then do
        --traceShowM (i,length a)
        forM [i..i+(length a)-1] $ \i' -> modifyArray arr (y,i') (+(length a))
        sub arr (i+(length a)) bs
      else do
        sub arr (i+(length a)) bs

g :: Field s -> Int -> [[Char]] -> ST s ()
g arr' x [] = return ()
g arr' x (s:field) = do
  sub arr' 1 $ group s
  g arr' (x+1) field
  where
    sub :: Field s -> Int -> [[Char]] -> ST s ()
    sub arr i [] = return ()
    sub arr i (a:bs) = if head a == '.' then do
        --traceShowM (i,length a)
        forM [i..i+(length a)-1] $ \i' -> modifyArray arr (i',x) (+(length a))
        sub arr (i+(length a)) bs
      else do
        sub arr (i+(length a)) bs

solve :: Int -> Int -> [[Char]] -> ST s Int
solve h w field = do
  arr <- newListArray ((1,1),(h,w)) $ repeat (-1)
  --fileld <- newlistArray ((1,1),(h,w)) $ concat list
  f arr 1 field
  --traceShowM $ show "---------------------"
  g arr 1 (transpose field)
  list <- forM [1..h] $ \y -> do
    forM [1..w] $ \x -> do
      readArray arr (y,x)

  return $ maximum $ concat list

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

main0 :: B.ByteString -> Int
main0 cont =
   let remLines0 = map B.words (B.lines cont)
       [h',w']:remLines1 = remLines0
       h = readBInt h'
       w = readBInt w'
       hs = map (B.unpack . head) (take h (remLines1))
   in runST $ solve h w hs

main :: IO ()
main = print . main0 =<< B.getContents
