#include <bits/stdc++.h>
using namespace std;
vector<int> arr[10001];
bool vis[10001];
void dfs(int node) {
  vis[node] = true;
  for (int child : arr[node]) {
    if (!vis[child]) {
      dfs(child);
    }
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, a, cc = 0;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> a;
    arr[a].push_back(i);
    arr[i].push_back(a);
  }
  for (int i = 1; i < n + 1; i++) {
    if (!vis[i]) {
      dfs(i);
      cc++;
    }
  }
  cout << cc;
  return 0;
}
