import qualified Data.IntMap as M              

main :: IO ()
main = do
    n  <- readLn
    as <- map read . words <$> getLine
    print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = go mp0
  where
    mp0 = M.fromList $ zip [1 .. n] as

    go :: M.IntMap Int -> Int
    go mp = case M.minViewWithKey mp of
        Nothing -> 0
        Just ((k, a), mp') | M.lookup a mp' == Just k -> 1 + go mp'
                           | otherwise                -> go mp'