import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main extends App {
  def solve: Unit = {
    val sc = new Scanner(System.in)
    val N = sc.next.toInt
    val A = (1 to N).map(a => sc.next.toInt);

    println((0 until N).count(i => A(A(i) - 1) == i + 1) / 2)
  }

  solve
}
