import qualified Data.Set as Set
import Data.Tuple

main = do
    getLine
    rabbits <- fmap (Set.fromList . zip [(1 :: Int)..] . fmap (read :: String -> Int) . words) getLine
    print $ (Set.size (rabbits `Set.intersection` (Set.map swap rabbits))) `div` 2