let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a - 1 in
  Printf.printf "%d\n" @@ (fun n -> n / 2) @@
    Array.fold_left ( + ) 0 @@
    Array.init n @@ fun i -> if as_.(as_.(i)) = i then 1 else 0
