#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, a;
  bool visit[10010];
  vector<int> v[10010];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a;
    v[i].push_back(a);
    v[a].push_back(i);
  }
  memset(visit, false, sizeof(visit));
  a = 0;
  for (i = 1; i <= n; i++) {
    if (!visit[i]) {
      a++;
      queue<int> q;
      visit[i] = true;
      q.push(i);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (j = 0; j < v[u].size(); j++) {
          if (!visit[v[u][j]]) {
            visit[v[u][j]] = true;
            q.push(v[u][j]);
          }
        }
      }
    }
  }
  cout << a << endl;
}
