open System

let ReadOne T = stdin.ReadLine()|> T
let ReadSplit T = stdin.ReadLine().Split()|>Array.map T
[<EntryPoint>]
let main argv =
    let N =ReadOne int
    let a=ReadSplit int
    let mutable ans=0.0f
    for i in [0..N-1] do
        ans <- ans + (if a.[a.[i]-1]=i+1 then 0.5f else 0.0f)
    ans
    |>int
    |>stdout.WriteLine
    0
