let N = Int(readLine()!)!
let A = readLine()!.characters.split(separator: " ").map { Int(String($0))! }

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