#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
bool used[10005], c[10005][10005];
vector<int> g[10005];
void dfs(int v) {
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to]) {
      dfs(to);
    }
  }
}
int main() {
  int n, m, k;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (!c[a][i]) {
      g[a].push_back(i);
      g[i].push_back(a);
      c[a][i] = 1;
      c[i][a] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans;
}
