#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  int n;
  vector<int> parent, rank, num;
  int find(int x) {
    if (parent[x] == x) return x;
    return parent[x] = find(parent[x]);
  }
  UnionFind(int n_) {
    n = n_;
    parent.resize(n);
    for (int i = 0; i < n; i++) parent[i] = i;
    rank.assign(n, 0);
    num.assign(n, 1);
  }
  void unite(int x, int y) {
    if ((x = find(x)) != (y = find(y))) {
      if (rank[x] < rank[y]) {
        parent[x] = y;
        num[y] += num[x];
      } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
        num[x] += num[y];
      }
      n--;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int get() { return n; }
  int get(int x) { return num[find(x)]; }
};
int main() {
  int n;
  scanf("%d", &n);
  vector<int> p(n);
  for (int i = 0; (i) < (int)(n); (i)++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  UnionFind uf(n);
  for (int i = 0; (i) < (int)(n); (i)++) {
    int pp = p[i];
    int ppp = p[pp];
    uf.unite(i, pp);
    uf.unite(i, ppp);
    uf.unite(pp, ppp);
  }
  printf("%d\n", uf.get());
  return 0;
}
