#include <bits/stdc++.h>
using namespace std;
long par[10001];
long root(long v) { return par[v] < 0 ? v : (par[v] = root(par[v])); }
void merge(long x, long y) {
  if ((x = root(x)) == (y = root(y))) return;
  if (par[y] < par[x]) swap(x, y);
  par[x] += par[y];
  par[y] = x;
}
int main() {
  long n, i, ans = 0;
  cin >> n;
  long a[n];
  for (i = 1; i <= n; i++) par[i] = -1;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    merge(i + 1, a[i]);
  }
  for (i = 1; i <= n; i++) {
    if (par[i] < 0) ans++;
  }
  cout << ans << endl;
}
