import Foundation

let number = readLine(stripNewline: true)
let numbers_arr_str = readLine(stripNewline: true)

let numbers_arr = numbers_arr_str!.componentsSeparatedByString(" ")
var no_pair = 0

for (i, value) in numbers_arr.enumerate() {
    let value_int = Int(value)! - 1
    if let index = Int(numbers_arr[value_int]) where index - 1 == i {
        no_pair += 1
    }
 }

no_pair = no_pair / 2

print(no_pair)