#include <bits/stdc++.h>
using namespace std;
vector<int> adj[10000 + 5];
int vis[10000 + 5];
void dfs(int s) {
  vis[s] = 1;
  for (int i = 0; i < adj[s].size(); i++) {
    if (vis[adj[s][i]] == 0) {
      dfs(adj[s][i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    adj[i].push_back(a);
    adj[a].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    vis[i] = 0;
  }
  int count = 1;
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      count++;
      dfs(i);
    }
  }
  cout << count << '\n';
  return 0;
}
