#include <bits/stdc++.h>
using namespace std;
vector<int> q[10000 + 1];
int flag[10000 + 1];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int d;
    cin >> d;
    q[d].push_back(i);
    q[i].push_back(d);
  }
  int s = 0;
  for (int i = 1; i <= n; i++) {
    if (flag[i]) continue;
    s++;
    int exe = 0;
    int empty = 1;
    int dfs[10000 + 1];
    dfs[exe] = i;
    flag[i] = 1;
    while (exe != empty) {
      for (int i = 0; i < q[dfs[exe]].size(); i++) {
        if (flag[q[dfs[exe]][i]]) {
          continue;
        }
        dfs[empty++] = q[dfs[exe]][i];
        flag[q[dfs[exe]][i]] = 1;
      }
      exe++;
    }
  }
  cout << s;
}
