#include <bits/stdc++.h>
using namespace std;
int root(vector<int> &Arr, int i) {
  while (Arr[i] != i) {
    Arr[i] = Arr[Arr[i]];
    i = Arr[i];
  }
  return i;
}
void weighted_union(vector<int> &Arr, vector<int> &size, int A, int B) {
  int root_A = root(Arr, A);
  int root_B = root(Arr, B);
  if (size[root_A] < size[root_B]) {
    Arr[root_A] = Arr[root_B];
    size[root_B] += size[root_A];
  } else {
    Arr[root_B] = Arr[root_A];
    size[root_A] += size[root_B];
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  vector<int> size(n + 1, 1);
  vector<int> b(n + 1);
  for (int i = 0; i < n; i++) b[i + 1] = i + 1;
  for (int i = 1; i <= n; i++) {
    weighted_union(b, size, i, a[i]);
  }
  int sum = 0;
  vector<int> c(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (c[i] == 1) continue;
    c[i] = 1;
    for (int j = i + 1; j <= n; j++) {
      if (root(b, i) == root(b, j)) c[j] = 1;
    }
    sum++;
  }
  cout << sum << endl;
}
