function Main(input) {
  input = input.split("\n");
  num = parseInt(input[0]);
	array = input[1].split(" ");
  array = array.map(el => {
    return parseInt(el);
  })
  var result = 0;
  array.forEach((element, index, array) => {
    if(index+1 === array[element-1]){
      result++;
    }
  })
  console.log(result/2);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));