#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18L + 5;
struct Data {
  long long int p;
  long long int h;
};
void ini() {}
bool comp(pair<long long int, long long int> &a,
          pair<long long int, long long int> &b) {
  if (a.first == b.first) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
vector<long long int> adj[200005];
vector<long long int> par, dis, col;
vector<bool> vis;
long long int gcd(long long int a, long long int b) {
  while (a != 0) {
    long long int temp = a;
    a = b % a;
    b = temp;
  }
  return b;
}
void dfs(long long int v) {
  vis[v] = true;
  for (long long int u : adj[v]) {
    if (!vis[u]) {
      dfs(u);
    }
  }
}
void solve() {
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long long int i = (long long int)(1); i < (long long int)(n + 1); i++) {
    cin >> a[i];
    adj[i].push_back(a[i]);
    adj[a[i]].push_back(i);
  }
  vis.assign(n + 1, false);
  long long int ans = 0;
  for (long long int i = (long long int)(1); i < (long long int)(n + 1); i++) {
    if (!vis[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans;
  cout << "\n";
  ;
}
int main() {
  ini();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
