import Text.Regex
import Data.Array

main :: IO ()
main= do
  cn<-getLine
  let n = read cn::Int
  dat<-getLine
  let listeddat = map read (words dat)::[Int]
  let arr       = listArray (1,n) listeddat
  print (solve arr n)

solve:: Array Int Int -> Int -> Int
solve arr n = div (sum [if x == arr ! (arr ! x) then 1 else 0 | x <- [1..n]]) 2
