#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = 3.141592653589793238462;
class UF {
 private:
  vector<int> parent;
  vector<int> rank;
  int count;
  int N;
  bool validate(int p) { return (p >= 0 && p < N); }

 public:
  UF(int N) : parent(N), rank(N, 0), N(N), count(N) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
    }
  }
  int find(int p) {
    if (!validate(p)) return -1;
    while (p != parent[p]) {
      parent[p] = parent[parent[p]];
      p = parent[p];
    }
    return p;
  }
  int getCount() const { return count; }
  bool connected(int p, int q) { return find(p) == find(q); }
  void Union(int p, int q) {
    int rootP = find(p);
    int rootQ = find(q);
    if (rootP == rootQ) return;
    if (rank[rootP] < rank[rootQ])
      parent[rootP] = rootQ;
    else if (rank[rootP] > rank[rootQ])
      parent[rootQ] = rootP;
    else {
      parent[rootQ] = rootP;
      rank[rootP]++;
    }
    count--;
  }
  ~UF() {}
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  UF uf(n);
  int rel;
  for (int i = 0; i < n; i++) {
    cin >> rel, rel--;
    uf.Union(i, rel);
  }
  cout << uf.getCount() << '\n';
  return 0;
}
