#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> adj;
vector<bool> used;
void dfs(int v) {
  used[v] = true;
  for (int to : adj[v]) {
    if (!used[to]) {
      dfs(to);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin >> n;
  adj.resize(n + 1);
  used.assign(n + 1, false);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    adj[i].push_back(x);
    adj[x].push_back(i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i);
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
