import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array.Unboxed

main :: IO ()
main = do
  n <- getl toInt
  solve n <$> getl (wrds toInt) >>= print

solve :: Int -> [Int] -> Int
solve n xs = foldl f 0 [1..n] `div` 2
  where
    ar = listArray (1,n) xs :: UArray Int Int
    f c ix
      | ar ! (ar ! ix) == ix = c + 1
      | otherwise = c

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine
