import Data.List
    
main :: IO ()
main =
  fmap read getLine >>=
  \n -> fmap ((zipWith (+) [1..n]) . (map read) . words) getLine >>=
  \as -> putStrLn $ show (length $ filter (\x -> (length x) == 2) $ group $ sort as)