object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readLine().toInt
    val a = io.StdIn.readLine().split(' ').map(_.toInt)

    val b = for (i <- 1 to n) yield {
      if (a(i - 1) <= i) false
      else if (a(a(i - 1) - 1) == i) true
      else false
    }

    println(b.filter(_ == true).length)
  }
}
