#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[10005];
bool vis[10005] = {false};
void dfs(long long root) {
  vis[root] = true;
  for (auto i : adj[root]) {
    if (!vis[i]) dfs(i);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  long long tree = 0;
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      tree++;
      dfs(i);
    }
  }
  cout << tree;
}
