
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord




r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)


main :: IO ()
main = do
    [h,w] <- r'

    yoko <- replicateM h getLine
    let tate = transpose yoko

    let yokoP = map (map length . group) yoko
    let tateP = map (map length . group) tate

    let yokoH = zip (map ((=='#') . head) yoko) yokoP
    let tateH = zip (map ((=='#') . head) tate) tateP

    let yokoP' = map (\(h,xs) -> unwind h xs) yokoH
    let tateP' = map (\(h,xs) -> unwind h xs) tateH

    let tateAsYoko = V.concat $ transpose' tateP'
    let yokoFin = V.concat yokoP'

    let res = V.map pred $ V.zipWith (+) tateAsYoko yokoFin

    print $ V.maximum res



transpose' :: [V.Vector Int] ->  [V.Vector Int]
transpose' [] = []
transpose' xs = (V.fromList $ map V.head xs):(transpose' (tail xs))


unwind :: Bool -> [Int] ->  V.Vector Int
unwind headIsDark xs = let f = if headIsDark then id else tail in 
        V.fromList $ concat $ zipWith unwAux ((f . cycle) [True,False]) xs


unwAux :: Bool -> Int -> [Int]
unwAux True  c = replicate c 0
unwAux False c = replicate c c

