#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
struct custom_hash {
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    x ^= FIXED_RANDOM;
    return x ^ (x >> 16);
  }
};
vector<int> ar[10001];
bool vis[10001];
void dfs(int node) {
  vis[node] = true;
  for (int child : ar[node]) {
    if (!vis[child]) dfs(child);
  }
}
void calConnComp(int n) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, u;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> u;
    if (u != i && (find(ar[i].begin(), ar[i].end(), u) == ar[i].end())) {
      ar[u].push_back(i);
      ar[i].push_back(u);
    }
  }
  calConnComp(n);
  return 0;
}
