#include <bits/stdc++.h>
using namespace std;
int visit[10009];
vector<int> g[10009];
void dfs(int s) {
  visit[s] = 1;
  for (int i = 0; i < g[s].size(); i++) {
    if (!visit[g[s][i]]) dfs(g[s][i]);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    g[i].push_back(x);
    g[x].push_back(i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (visit[i] != 1) {
      ans++;
      dfs(i);
    }
  }
  cout << ans << endl;
  return 0;
}
