import Data.Array
import Data.Array.IO
import Control.Monad

type Grid = IOUArray (Int,Int) Char
type DP = IOUArray (Int,Int) Int

main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  xss <- replicateM h getLine 
  grid <- thaw $ listArray ((1,1),(h,w)) $ concat xss :: IO Grid
  dp <- newArray ((1,1),(h,w)) (10^9) :: IO DP

  readArray grid (1,1) >>= \r -> do
    if r == '#'
       then writeArray dp (1,1) 1
       else writeArray dp (1,1) 0

  ((minh,minw), (maxh,maxw)) <- getBounds dp

  forM_ [1..h] $ \i -> do
    forM_ [1..w] $ \j -> do
      d <- readArray dp (i,j) 
      forM_ [(i+1,j),(i,j+1)] $ \p@(i',j') -> do
        unless (i' < minh || j' < minw || i' > maxh || j' > maxw) $ do
          readArray grid p >>= \r ->
            if r == '#'
               then readArray dp p >>= \s -> writeArray dp p $ min (d+1) s
               else readArray dp p >>= \s -> writeArray dp p $ min d s

  readArray dp (h,w) >>= print
