#include <bits/stdc++.h>
using namespace std;
set<pair<signed long long int, signed long long int> >::iterator it;
signed long long int arr[10001];
signed long long int size[10001];
void initialize(signed long long int n) {
  for (signed long long int i = 1; i <= n; i++) {
    arr[i] = i;
    size[i] = 1;
  }
}
signed long long int root(signed long long int i) {
  while (i != arr[i]) {
    arr[i] = arr[arr[i]];
    i = arr[i];
  }
  return i;
}
void dsu_union(signed long long int a, signed long long int b) {
  signed long long int ra = root(a);
  signed long long int rb = root(b);
  if (ra != rb) {
    if (size[ra] < size[rb]) {
      arr[ra] = rb;
      size[rb] += size[ra];
    } else {
      arr[rb] = ra;
      size[ra] += size[rb];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  signed long long int n;
  cin >> n;
  initialize(n);
  for (signed long long int i = 1; i <= n; i++) {
    signed long long int x;
    cin >> x;
    dsu_union(i, x);
  }
  signed long long int ans = 0;
  for (signed long long int i = 1; i <= n; i++) {
    if (arr[i] == i) ans++;
  }
  cout << ans << "\n";
  return 0;
}
