#include <bits/stdc++.h>
using namespace std;
#pragma optimize("g", on)
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("03")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long inf = 1e18;
const long long N = 1e5 + 1;
long long was[N];
vector<long long> adj[N];
void dfs(long long u) {
  was[u] = 1;
  for (auto e : adj[u]) {
    if (!was[e]) {
      dfs(e);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long p[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> p[i];
    adj[i].push_back(p[i]);
    adj[p[i]].push_back(i);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (!was[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans;
}
