#include <bits/stdc++.h>
using namespace std;
pair<int, int> p1;
int a[1234567];
int dp[1001];
int n, p[100000], f[100000], i, k, l;
set<int> s;
long long pow1(long long x, long long y) {
  if (y == 0) return 1;
  long long temp = pow1(x, y / 2) % 1000000007;
  if (y % 2 == 0)
    return (temp * temp) % 1000000007;
  else
    return (((temp * temp) % 1000000007) * x) % 1000000007;
}
int find(int x) { return (x == f[x] ? x : find(f[x])); }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    f[i] = i;
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    k = find(i);
    l = find(p[i]);
    if (k != l) {
      f[k] = l;
    }
  }
  for (i = 1; i <= n; i++) {
    s.insert(find(i));
  }
  printf("%d\n", s.size());
  return 0;
}
