#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 55;
const int M = 1e9 + 7;
int n, a[N];
vector<int> v[N];
void man(int j) {
  if (a[j] == 0) {
    a[j] = 1;
    for (auto i = v[j].begin(); i != v[j].end(); ++i) {
      int w = (int)*i;
      if (a[w] == 0) {
        man(w);
      }
    }
  } else {
    return;
  }
}
int ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int q;
    cin >> q;
    v[i].push_back(q);
    v[q].push_back(i);
  }
  int ok = 0;
  while (ok == 0) {
    int q = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i] == 0) {
        man(i);
        q++;
        break;
      }
    }
    if (q == 0) {
      cout << ans << endl;
      exit(0);
    }
    ans++;
  }
  return 0;
}
