import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.Unboxed

main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    let ary = listArray (1, n) as :: UArray Int Int
    let ans = length $ filter (\(i, a) -> ary ! a == i) (zip [1..] as)
    print (ans `div` 2)