#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1e4 + 5;
int arr[N];
int main()
{
int n, res = 0;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &arr[i]);
for (int i = 1; i <= n; ++i)
{
while (arr[i] != i)
{
++res;
swap(arr[i], arr[arr[i]]);
}
}
printf("%d", res);
return 0;
}