#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
vector<long long> vec[10005];
long long vis[10005];
long long i, n, a, cnt = 0;
void dfs(int x) {
  if (vis[x] == 1) return;
  vis[x] = 1;
  for (int i = 0; i < vec[x].size(); i++) {
    long long y = vec[x][i];
    if (vis[y] == 0) dfs(y);
  }
}
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a);
      vec[i].push_back(a);
      vec[a].push_back(i);
    }
    memset(vis, 0, sizeof vis);
    cnt = 0;
    for (i = 1; i <= n; i++) {
      if (vis[i] == 0) {
        ++cnt;
        dfs(i);
      }
    }
    printf("%lld\n", cnt);
    for (i = 1; i <= n; i++) vec[i].clear();
  }
  return 0;
}
