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

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

		println(result)
	}
}