#include <bits/stdc++.h>
using namespace std;
const int NMAX = 10005;
int n;
int ht[NMAX], par[NMAX];
int ans;
int root(int node) {
  while (par[node]) node = par[node];
  return node;
}
void unite(int x, int y) {
  int a = root(x);
  int b = root(y);
  if (a == b) return;
  if (ht[a] > ht[b]) {
    par[b] = a;
    ht[b] = 0;
  } else {
    par[a] = b;
    if (ht[a] == ht[b]) ++ht[b];
    ht[a] = 0;
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  memset(ht, 1, sizeof(ht));
  for (int i = 1; i <= n; ++i) {
    int temp;
    cin >> temp;
    unite(i, temp);
  }
  for (int i = 1; i <= n; ++i)
    if (ht[i]) ++ans;
  cout << ans << "\n";
  return 0;
}
