import Data.List
-- a_i==a_i+1の場合の処理をしてないのでWA
readInt :: String -> Int
readInt = read

main = do
    s <- tail.map readInt.words<$>getContents
    print $ solve s

solve s = f (odds s) + f (evens s)

odds [] = []
odds [a] = [a]
odds [a,b] = [a]
odds (a:b:x) = a:(odds x)

evens s = odds (tail s)

f s = length(nub s) - 1