#include <bits/stdc++.h>
using namespace std;
vector<int> adj[10001];
int visited[10001] = {0};
void dfs(int u) {
  visited[u] = 1;
  for (int i = 0; i < adj[u].size(); ++i) {
    if (visited[adj[u][i]] == 0) dfs(adj[u][i]);
  }
}
int main() {
  int n, p, tree = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p;
    --p;
    adj[i].push_back(p);
    adj[p].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    if (visited[i] == 0) {
      dfs(i);
      tree++;
    }
  }
  cout << tree << endl;
}
