main :: IO ()
main =
  fmap read getLine >>=
  \n -> fmap ((map read) . words) getLine >>=
  \as -> putStrLn $ show $ (solve n as) `div` 2

solve :: Int -> [Int] -> Int
solve n as = sum $ zipWith (\x y -> if x == y then 1 else 0) (sub as as) [1..n]

sub :: [Int] -> [Int] -> [Int]
sub [] xs  = []
sub (a:as) xs = (xs !! (a-1)) : (sub as xs)