#include <bits/stdc++.h>
using namespace std;
struct DSU {
  vector<int> parents;
  vector<int> sizes;
  DSU(int n) {
    parents.resize(n);
    for (int i = 0; i < n; i++) parents[i] = i;
    sizes.resize(n);
    for (int i = 0; i < n; i++) sizes[i] = 1;
  }
  int find_set(int a) {
    if (parents[a] != a) {
      parents[a] = find_set(parents[a]);
    }
    return parents[a];
  }
  void union_sets(int a, int b) {
    int setA = find_set(a);
    int setB = find_set(b);
    if (setA != setB) {
      if (sizes[setA] > sizes[setB]) {
        parents[setB] = setA;
      } else {
        parents[setA] = setB;
      }
    }
  }
  int num_sets() {
    set<int> s;
    for (int i = 0; i < parents.size(); i++) {
      s.insert(find_set(i));
    }
    return s.size();
  }
};
int main() {
  int n;
  cin >> n;
  DSU dsu(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x--;
    dsu.union_sets(i, x);
  }
  cout << dsu.num_sets() << endl;
}
