#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 100010;
vector<int> graph[N];
int us[N];
void dfs(int u) {
  us[u] = 1;
  for (int v : graph[u])
    if (!us[v]) dfs(v);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    graph[i].push_back(x);
    graph[x].push_back(i);
  }
  int r = 0;
  for (int i = 1; i <= n; i++)
    if (!us[i]) {
      dfs(i);
      r++;
    }
  printf("%d\n", r);
  return 0;
}
