#include <bits/stdc++.h>
using namespace std;
void dfs_util(int i, vector<int> adj[], bool visited[]) {
  visited[i] = true;
  for (int j = 0; j < adj[i].size(); j++) {
    if (visited[adj[i][j]] == false) {
      dfs_util(adj[i][j], adj, visited);
    }
  }
}
int dfs(vector<int> adj[], int n) {
  int count = 0;
  bool visited[n + 1];
  for (int i = 1; i <= n; i++) {
    visited[i] = false;
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      count++;
      dfs_util(i, adj, visited);
    }
  }
  return count;
}
int main() {
  int n;
  cin >> n;
  vector<int> adj[10004];
  int p[n + 1];
  int count;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    adj[p[i]].push_back(i);
    adj[i].push_back(p[i]);
  }
  cout << dfs(adj, n);
}
