import Data.List
import Control.Applicative

darker lines = map (map repl . darker_aux) $ transpose $ map darker_aux lines
  where
    repl '*' = '#'
    repl c = c
    darker_aux [] = []
    darker_aux ('.':'#':remains) = '*':(darker_aux ('#':remains))
    darker_aux ('#':'.':remains) = '#':'*':(darker_aux remains)
    darker_aux (c:remains) = c:(darker_aux remains)

num_darker lines = num_darker_aux lines 0
  where
    num_darker_aux lines n
      | lines == next = n
      | otherwise = num_darker_aux next (n+1)
      where
        next = darker lines

main = do
  (h:w:_) <- map (read :: String -> Int) . words <$> getLine
  a <- lines <$> getContents
  print $ num_darker a