import qualified Data.Set as S 

main = do
 getLine
 as <- map read . words <$> getLine
 let likeTo = S.fromDistinctAscList (zip [1..] as)
 let likeFrom = S.fromList (zip as [1..])
 print $ S.size (S.intersection likeTo likeFrom) `div` 2