#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > m;
map<int, int> vs;
int counter = 0;
void dfs(int node) {
  if (vs[node] == 0) {
    vs[node] = 1;
    for (int i = 0; i < m[node].size(); i++) dfs(m[node][i]);
  }
}
int main() {
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    m[i].push_back(x);
    m[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (vs[i] == 0) counter++, dfs(i);
  }
  cout << counter;
  return 0;
}
