object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val rabbits = Array.fill(N)(sc.nextInt())
  println((0 until N).count(i => rabbits(rabbits(i) - 1) - 1 == i) / 2)
}
