module Main where
import Data.List

int = read :: String -> Int

main = interact $ printer . solver . parser

printer = unlines . (:[]) . show

parser = map int . tail . words

solver :: [Int] -> Int
solver is = counter tf 
  where
    tf = zipWith (==) is [1..]
    counter [] = 0
    counter (True:[]) = 1
    counter (False:[]) = 0
    counter (True:True:tfs) = 1 + counter tfs
    counter (False:True:tfs) = counter (True:tfs)
    counter (True:False:tfs) = 1 + counter tfs
    counter (False:False:tfs) = counter tfs
