#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, ans = 0;
	cin >> N;
	vector<int> a(N);
	for (int& i : a) cin >> i;
	for (int i = 0; i < N; ++i) {
		if (1 + i == a[a[i] - 1]) ++ans;
	}
	cout << ans / 2;
}