#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int R = 4000001;
const long long inf = (long long)1e12;
const double pi = (double)acos(-1);
int n;
int m;
int k;
int q;
int type, l, r, x, y;
int u, v, w;
int a, b, c;
bool composite[N];
int uf[N];
int FIND(int u) {
  if (uf[u] != uf[uf[u]]) {
    return uf[u] = FIND(uf[u]);
  }
  return uf[u];
}
bool join(int u, int v) {
  u = FIND(u), v = FIND(v);
  if (u != v) {
    uf[u] = v;
  }
  return 1;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    uf[i] = i;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> u;
    join(i, u);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += FIND(i) == i;
  }
  cout << ans << endl;
}
