#include <iostream>
using namespace std;

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