#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> A(n), P(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    --A[i];
    P[i] = i;
  }
  auto find = [&](int x) {
    vector<int> amigos;
    while (x != P[x]) {
      amigos.push_back(x);
      x = P[x];
    }
    while (!amigos.empty()) {
      P[amigos.back()] = x;
      amigos.pop_back();
    }
    return x;
  };
  for (int i = 0; i < n; i++) {
    int x = i, y = A[i];
    if ((x = find(x)) != (y = find(y))) {
      P[x] = y;
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    ans[find(i)] = 1;
  }
  for (int i = n - 1; i > 0; i--) {
    ans[i - 1] += ans[i];
  }
  cout << ans[0] << "\n";
  return 0;
}
