#include <bits/stdc++.h>
using namespace std;
int a[10009], n, m, vis[10009], cnt;
vector<int> yol[10009];
void dfs(int v) {
  vis[v] = 1;
  for (auto to : yol[v]) {
    if (!vis[to]) dfs(to);
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  ;
  for (i = (1); i <= (n); i++) {
    scanf("%d", &a[i]);
    yol[a[i]].push_back(i), yol[i].push_back(a[i]);
  }
  memset(vis, 0, sizeof(vis));
  ;
  for (i = (1); i <= (n); i++) {
    if (vis[i]) continue;
    dfs(i), cnt++;
  }
  printf("%d", cnt);
}
