#include <iostream>
using namespace std;
int group(int* data, bool* used, int current)
{
if (used[current] == true) return 0;
else
{
used[current] = true;
group(data, used, data[current]);
}
}
int main()
{
int n;
cin >> n;
int firend[50001] = { 0 };
for (int i = 0; i < n; i++)
{
cin >> firend[i];
}
bool *used = new bool[n] { false };
int ans = 0;
for (int i = 0; i < n; i++)
{
if(used[i] == false)
{
group(firend, used, i);
ans++;
}
}
cout << ans;
}