#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  signed long long N;
  cin >> N;
  vector<vector<signed long long>> adj(N, vector<signed long long>());
  for (signed long long i = 0; i < N; i++) {
    signed long long a;
    cin >> a;
    a--;
    adj[a].push_back(i);
    adj[i].push_back(a);
  }
  vector<bool> vis(N, false);
  queue<signed long long> next;
  signed long long sol = 0;
  for (signed long long i = 0; i < N; i++) {
    if (!vis[i]) {
      sol++;
      vis[i] = true;
      next.push(i);
      while (!next.empty()) {
        signed long long node = next.front();
        next.pop();
        for (signed long long connected : adj[node]) {
          if (!vis[connected]) {
            vis[connected] = true;
            next.push(connected);
          }
        }
      }
    }
  }
  cout << sol;
  return 0;
}
