fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val pairs = mutableSetOf<Int>()

    aa.forEachIndexed { index, i ->
        if (aa[i-1] == index + 1) {
            pairs.add(index + 1)
            pairs.add(i)
        }
    }

    println(pairs.size / 2)
}