#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int n, m;
vector<vector<int> > g;
vector<bool> used;
void dfs(int v) {
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    if (used[g[v][i]] == 0) {
      dfs(g[v][i]);
    }
  }
}
int main() {
  cin >> n;
  g.resize(n, vector<int>());
  used.resize(n, 0);
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a;
    a--;
    g[i].push_back(a);
    g[a].push_back(i);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (used[i] == 0) {
      dfs(i);
      cnt++;
    }
  }
  cout << cnt;
}
