
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val N = StdIn.readLine().toInt
    val An = StdIn.readLine().split(" ").map(_.toInt)
    println(An.zipWithIndex.count { case (a, i) => An(a - 1) == (i+1) } / 2)
  }
}
