#include <bits/stdc++.h>
using namespace std;
long long cnt;
bool visited[10009];
vector<long long> g[10009];
void dfs(long long n) {
  visited[n] = 1;
  for (long long i = 0; i < g[n].size(); i++) {
    long long u = g[n][i];
    if (visited[u] == 0) {
      dfs(u);
      cnt++;
    }
  }
}
int main() {
  long long i, j, k, l, m, n;
  while (cin >> n) {
    for (i = 0; i < 10009; i++) {
      g[i].clear();
    }
    memset(visited, 0, sizeof(visited));
    for (i = 1; i <= n; i++) {
      cin >> m;
      g[i].push_back(m);
      g[m].push_back(i);
    }
    long long ans = 0;
    for (i = 1; i <= n; i++) {
      if (visited[i] == 0) {
        ans++;
        dfs(i);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
