#include <bits/stdc++.h>
using namespace std;
class Solution {
  int n;
  vector<vector<int>> adj;
  vector<bool> visited;

 public:
  Solution() {
    cin >> n;
    adj.resize(n);
    for (int i = 0; i < n; ++i) {
      int pi;
      cin >> pi;
      --pi;
      adj[i].push_back(pi);
      adj[pi].push_back(i);
    }
    cout << solve();
  }
  int solve() {
    visited.resize(n);
    int trees_count = 0;
    for (int i = 0; i < n; ++i) {
      if (!visited[i]) {
        dfs(i);
        ++trees_count;
      }
    }
    return trees_count;
  }
  void dfs(int u) {
    visited[u] = true;
    for (int v : adj[u]) {
      if (!visited[v]) {
        dfs(v);
      }
    }
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  Solution solution;
}
