import Data.List
import Data.Bool

main = print . solve . map read . drop 1 . words =<< getContents

solve :: [Int] -> Int
solve xs = solve' 0 xs'
    where
        xs' = zipWith (==) [1..] xs

solve' c [] = c
solve' c [x] = bool c (c+1) x
solve' c (x:y:xs)
    | x && y = solve' (c+1) xs
    | x = solve' (c+1) xs
    | otherwise = solve' c xs
