import Data.List
import qualified Data.Vector.Unboxed as V
main=do
    n<-readLn::IO Int
    as<-V.fromList.map read.words<$>getLine::IO(V.Vector Int)
    print $ (`div` 2) $ length $ filter (\i->as V.! ((as V.! i)-1) == (i+1)) [0..n-1]
