#include <bits/stdc++.h>
using namespace std;
void initialize(long long int a[], long long int size[], long long int n) {
  for (int i = 0; i < n; i++) {
    a[i] = i;
    size[i] = 1;
  }
}
long long int root(long long int a[], long long int i) {
  while (a[i] != i) {
    i = a[a[i]];
  }
  return i;
}
void Union(long long int a[], long long int size[], long long int x,
           long long int y) {
  long long int rootx = root(a, x);
  long long int rooty = root(a, y);
  if (rootx == rooty) return;
  if (size[rootx] > size[rooty]) {
    a[rooty] = a[rootx];
    size[rootx] += size[rooty];
  } else {
    a[rootx] = a[rooty];
    size[rooty] += size[rootx];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n], size[n];
  initialize(a, size, n);
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    Union(a, size, i, x - 1);
  }
  long long int count = 0;
  for (long long int i = 0; i < n; i++)
    if (a[i] == i) count++;
  cout << count << "\n";
  return 0;
}
