'use strict';
const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const N = parseInt(inputs[0]);
const a = inputs[1].split(' ');

let cnt = 0;
for (let len = a.length, i = 1; i <= len; i++) {
	let j = parseInt(a[i - 1]);
	if (j < i) continue;
	
	if (parseInt(a[j - 1]) === i) cnt++;
}
console.log(cnt);