#include <iostream>
using namespace std;

int main() {
	int i,n,b;
	int ans=0;
	int a[n];
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>b;
		a[i]=b-1;
	}
	
	for(i=0;i<n;i++){
		if(a[a[i]]==i){
			ans++;
		}
	}
	
	cout<<ans/2<<endl;
}