#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18L + 5;
vector<vector<int>> g;
vector<int> vis;
void dfs(int u) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (!vis[v]) dfs(v);
  }
}
void solve() {
  long long n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<bool> done(n + 1);
  g = vector<vector<int>>(n + 1);
  for (int i = 1; i <= n; i++) {
    if (done[i]) continue;
    g[i].push_back(a[i]);
    g[a[i]].push_back(i);
    if (a[a[i]] == i) done[a[i]] = true;
  }
  vis = vector<int>(n + 1, 0);
  int trees = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      trees++;
    }
  }
  cout << trees;
}
int main() {
  int t = 1;
  long long k = 1;
  while (t--) {
    solve();
  }
  return 0;
}
