#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, vector<int> > map1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    map1[i].push_back(a);
    map1[a].push_back(i);
  }
  int counter = 0;
  map<int, bool> check;
  for (int i = 1; i <= n; i++) {
    if (!check[i]) {
      counter++;
      queue<int> que;
      que.push(i);
      while (que.size()) {
        int front = que.front();
        que.pop();
        if (!check[front])
          for (int j = 0; j < map1[front].size(); j++) {
            que.push(map1[front][j]);
          }
        check[front] = true;
      }
    }
  }
  cout << counter;
  return 0;
}
