#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > adj(10005);
int vis[10005];
void dfs(int u) {
  if (vis[u] == 1) return;
  vis[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int pp = adj[u][i];
    if (vis[pp] == 0) dfs(pp);
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(vis, 0, sizeof(vis));
  long long int n, num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    num--;
    adj[i].push_back(num);
    adj[num].push_back(i);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      dfs(i);
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
