import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	int[] as = readln.chomp.split.map!(to!int).map!(x => x - 1).array;
	
	int count = 0;
	
	foreach(i, a; as){
		if(i < a && as[a] == i) count ++;
		}
	
	count.writeln;
	
	}