(function() {
    'use strict';
    var lines = [];
    require('readline').createInterface({
        input: process.stdin,
        output: process.stdout
    })
        .on('line', function(line) {
            lines.push(line);
        });

    process.stdin.on('end', function() {
        main(lines);
    });
})();

function main(lines) {
    var numRabbits = +lines[0], count = 0;
    var likes = lines[1].split(' ');
    // for (var i=0; i<numRabbits; i++) {
    //     rabbits.push(likes);
    // }
    for (var i=0; i<likes.length; i++) {
        var myLike = likes[i];
        var myLikesLike = like[myLike-1];
        if (myLikesLike == i+1)
            count++
    }
    console.log(count);
}
