let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" pred
let c = ref 0
let _ = for i = 0 to n - 1 do if a_s.(a_s.(i)) = i then incr c done; Printf.printf "%d\n" @@ !c / 2