#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, siz = 2e5 + 5;
set<long long> g[siz];
long long n, m, a[siz];
bool vis[siz];
void go(long long u) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (vis[v]) continue;
    go(v);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    g[x].insert(i);
    g[i].insert(x);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (vis[i]) continue;
    go(i);
    ans++;
  }
  cout << ans << endl;
}
