#include <bits/stdc++.h>
using namespace std;
void IOS() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
}
long long int root(long long int a[], long long int i) {
  while (i != a[i]) {
    a[i] = a[a[i]];
    i = a[i];
  }
  return i;
}
void uni(long long int arr[], long long int siz[], long long int a,
         long long int b) {
  long long int root_a = root(arr, a);
  long long int root_b = root(arr, b);
  if (root_a == root_b) {
    return;
  } else if (siz[root_a] >= siz[root_b]) {
    siz[root_a] += siz[root_b];
    arr[root_b] = arr[root_a];
  } else {
    siz[root_b] += siz[root_a];
    arr[root_a] = arr[root_b];
  }
}
int32_t main() {
  IOS();
  long long int n;
  cin >> n;
  long long int a[n], parent[n], siz[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    parent[i] = i;
    siz[i] = 1;
  }
  for (long long int i = 0; i < n; i++) {
    uni(parent, siz, i, a[i]);
  }
  long long int no = 0;
  for (long long int i = 0; i < n; i++) {
    if (i == parent[i]) {
      no++;
    }
  }
  cout << no;
}
