#include <bits/stdc++.h>
using namespace std;
inline void deBugMode() {}
inline void optimizeIt() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
}
inline double ABS(const double &x) { return max(x, -x); }
const int NMax = 1e4 + 5;
const int LIM = 1e9;
const int MOD = 1e8;
vector<int> G[NMax];
bool viz[NMax];
inline void BFS(int node) {
  viz[node] = true;
  deque<int> de;
  de.push_back(node);
  while (!de.empty()) {
    node = de.front();
    de.pop_front();
    for (auto it : G[node]) {
      if (viz[it] == false) {
        viz[it] = true;
        de.push_back(it);
      }
    }
  }
}
int main() {
  deBugMode();
  optimizeIt();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    G[i].push_back(x);
    G[x].push_back(i);
  }
  int comp = 0;
  for (int i = 1; i <= n; i++) {
    if (viz[i] == false) {
      BFS(i);
      comp++;
    }
  }
  cout << comp;
  return 0;
}
