#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v;
int n, p[10001], res;
bool used[10001];
void dfs(int x) {
  used[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (!used[v[x][i]]) dfs(v[x][i]);
  }
}
int main() {
  cin >> n;
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    v[i].push_back(p[i]);
    v[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) {
      res++;
      dfs(i);
    }
  cout << res << endl;
}
