#include <bits/stdc++.h>
int main() {
  int total;
  int *arr;
  int i, j;
  int temp;
  int count;
  int *record;
  scanf("%d", &total);
  arr = (int *)malloc(sizeof(int) * (total + 1));
  record = (int *)malloc(sizeof(int) * (total + 1));
  memset(record, 0, sizeof(int) * (total + 1));
  for (i = 0; i <= total; i++) arr[i] = INT_MIN;
  for (i = 1, count = 0; i <= total; i++) {
    scanf("%d", &temp);
    if (arr[i] == INT_MIN) {
      if (arr[temp] == INT_MIN) {
        arr[i] = count;
        arr[temp] = count;
        count++;
      } else {
        arr[i] = arr[temp];
      }
    } else {
      if (arr[temp] == INT_MIN) {
        arr[temp] = arr[i];
      } else if (arr[temp] != arr[i]) {
        for (j = 1; j <= total; j++) {
          if (arr[j] == arr[temp]) arr[j] = arr[i];
        }
      }
    }
  }
  for (j = 1; j <= total; j++) {
    if (arr[j] >= 0) record[arr[j]] = 1;
  }
  for (j = 0, count = 0; j <= total; j++) {
    if (record[j]) count++;
  }
  printf("%d\n", count);
  free(arr);
  free(record);
  return 0;
}
