function Main(input){
    input = input.split('\n');
    array = input[1].split(" ");
    array= array.map(Number);

    var nakayoshi = 0;
    for (var index = 0; index < array.length; index++) {
        if(array[index] == array[array[index]-1]){
        }
        else if(array[index] < array[array[index]-1] ){
            if(array[array[index]-1] == index+1){
                nakayoshi = nakayoshi+1;
            }
        }else{}
    }
    console.log('%d',nakayoshi);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 