#include <bits/stdc++.h>
using namespace std;
int Arr[100001];
int root(int i) {
  while (Arr[i] != i) {
    i = Arr[i];
  }
  return i;
}
int union1(int A, int B) {
  int root_A = root(A);
  int root_B = root(B);
  Arr[root_A] = root_B;
}
void find(int A, int B) {
  if (root(A) != root(B)) union1(A, B);
}
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    Arr[i] = i;
  }
  int a;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    find(i, a);
  }
  for (int i = 1; i <= n; i++) {
    if (Arr[i] == i) ans++;
  }
  cout << ans;
  return 0;
}
