#include <bits/stdc++.h>
using namespace std;
void dfs(vector<long long int> graph[], long long int node,
         vector<bool>& visited) {
  visited[node] = true;
  for (long long int i = 0; i < graph[node].size(); i++) {
    long long int x = graph[node][i];
    if (!visited[x]) {
      dfs(graph, x, visited);
    }
  }
}
int main() {
  long long int n;
  cin >> n;
  vector<long long int> graph[n];
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    --x;
    graph[i].push_back(x);
    graph[x].push_back(i);
  }
  vector<bool> visited(n, false);
  long long int count = 0;
  for (long long int i = 0; i < n; i++) {
    if (!visited[i]) {
      dfs(graph, i, visited);
      count++;
    }
  }
  cout << count << "\n";
}
