#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> arr[], vector<int>& vis, int src) {
  vis[src] = 1;
  for (auto i : arr[src]) {
    if (!vis[i]) {
      dfs(arr, vis, i);
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> arr[n + 1];
  for (int i = 1; i < n + 1; i++) {
    int x;
    cin >> x;
    arr[i].push_back(x);
    arr[x].push_back(i);
  }
  vector<int> vis(n + 1, 0);
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    if (!vis[i]) {
      ans++;
      dfs(arr, vis, i);
    }
  }
  cout << ans << endl;
  return 0;
}
