import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

flags :: [Int] -> [Bool]
flags xs = map (\(a, b) -> a == b) $ zip xs [1 ..]

counts (True         : True  : xs) = 1 + counts xs
counts (True         : False : xs) = 1 + counts xs
counts (False : True : True  : xs) = 1 + counts xs
counts (False        : True  : xs) = 1 + counts xs
counts (False                : xs) = 0 + counts xs
counts [True                     ] = 1
counts []                          = 0

main = do
  n  <- readLn
  ns <- take n . map (read :: String -> Int) . words <$> getLine
  print $ counts $ flags ns

