
import Foundation

let numberOfRabits = readLine()
let arrayOfLikes = readLine()

let numberOfRabitsInt = Int(numberOfRabits!)!
let arrayOfLikesString = String(UTF8String: arrayOfLikes!)!

var mone = 0
var arrOfLikes = (arrayOfLikesString.characters.split(" ").map(String.init))

if arrOfLikes.count == 1 {
    print(1)
} else {
    var amountOfLikes = 0
    for i in 0 ... numberOfRabitsInt - 1 {
       
        let valueInCell = (Int(arrOfLikes[i]))!
        if valueInCell != i + 1 {
            if Int(arrOfLikes[valueInCell - 1])!  == i + 1 {
                amountOfLikes++
            }
        }
    }
    print(amountOfLikes / 2)

}
