import java.util.*
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    val N=sc.nextInt()
    val a=Array(N) {sc.nextInt()}
    var num=0

    for (j in 1..N)
    {
      val i=a[j-1]
      if (i>=j) continue
      num+=if(a[i-1]==j&&a[j-1]==i) 1 else 0
    }

    println(num)
  }
}
