#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, -1, 0, 1, -1, 1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const long double EPS = 1e-9;
const long double PI = 3.1415926535897932384L;
const long long int INF = 9223372036854775807;
const int MOD = 1000000000 + 7;
const int MAX = 10000000 + 7;
class UFD {
 private:
  vector<int> p, rank, setSizes;
  int numSets;

 public:
  UFD(int N) {
    numSets = N;
    rank.assign(N + 2, 0);
    p.assign(N + 2, 0);
    for (int i = 1; i <= N; i++) p[i] = i;
    setSizes.assign(N + 2, 1);
  }
  int findSet(int i) { return (p[i] == i) ? i : p[i] = findSet(p[i]); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y]) {
        setSizes[findSet(x)] += setSizes[findSet(y)];
        p[y] = x;
      } else {
        setSizes[findSet(y)] += setSizes[findSet(x)];
        p[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
      }
      numSets--;
    }
  }
  int setSize(int i) { return setSizes[findSet(i)]; }
  int numDisjointSets() { return numSets; }
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int N;
  cin >> N;
  UFD tree(N);
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    tree.unionSet(a, i);
  }
  return cout << tree.numDisjointSets() << endl, 0;
}
