let N = Int(readLine()!)!
let A = [0] + readLine()!.characters.split(" ").map { Int(String($0))! }

var result = 0
for i in 0 ..< A.count {
    if i < A[i] && A[A[i]] == i {
        result += 1
    }
}
print(result)
