import java.util.Scanner

object Main {
	def main(args: Array[String]) {
		val sc = new Scanner(System.in)
		val N = sc.nextInt()
		val a = List.fill(N)(sc.nextInt)

		val result = a.zipWithIndex.count( t => a(t._1 - 1) == (t._2 + 1)) / 2

		println(result)
	}
}