import Data.Array.Unboxed

type Tab = Array Int Int

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- zip [1..] <$> getInts
  let tab = accumArray (\_ c -> c) (-1) (1, n) ns :: Tab
  print $ solve tab n

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Tab -> Int -> Int
solve tab n = go [1..n] `div` 2
  where
    go [] = 0
    go (x:xs) = let b = tab ! x
                    a = tab ! b in
                  (if a == x then 1 else 0) + go xs
