#include <bits/stdc++.h>
using namespace std;
int n;
int p[10005], len[10005];
set<int> res;
vector<int> a(0);
int find_set(int v);
void union_sets(int a, int b);
int main() {
  int ii;
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  a.resize(n);
  for (ii = 0; ii < n; ii++) {
    cin >> a[ii];
    a[ii]--;
    p[ii] = ii;
    len[ii] = 1;
  }
  for (ii = 0; ii < n; ii++) union_sets(ii, a[ii]);
  for (ii = 0; ii < n; ii++) res.insert(find_set(ii));
  cout << res.size() << "\n";
  return 0;
}
int find_set(int v) {
  if (p[v] != v) p[v] = find_set(p[v]);
  return p[v];
}
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (len[a] < len[b]) swap(a, b);
    p[b] = a;
    len[a] += len[b];
  }
}
