#include <bits/stdc++.h>
using namespace std;
int par[10000 + 10];
int unionfind(int x) {
  if (par[x] == x) return x;
  return par[x] = unionfind(par[x]);
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) par[i] = i;
  int arr[10000 + 10];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    int x = arr[i], y = i;
    x = unionfind(arr[i]), y = unionfind(i);
    if (x != y) par[x] = y;
  }
  int frq[10000 + 10] = {0};
  for (int i = 1; i <= n; i++) {
    int x = unionfind(i);
    frq[x]++;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (frq[i] > 0) cnt++;
  }
  cout << cnt << endl;
}
void I_O() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  I_O();
  solve();
  return 0;
}
