object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt()-1)
  val map = a.zipWithIndex.map{case (e, i) => i -> e}.toMap
  val ans = map.count{ case (k, v) => map(v) == k} / 2
  println(ans)
}
