#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
const int NMAX = 10005;
int n, p[NMAX];
bitset<NMAX> viz;
vector<int> v[NMAX];
int sol;
void Dfs(int x) {
  viz[x] = 1;
  for (auto it : v[x])
    if (!viz[it]) Dfs(it);
}
int main() {
  cin.sync_with_stdio(false);
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
    v[i].push_back(p[i]);
    v[p[i]].push_back(i);
  }
  for (i = 1; i <= n; i++)
    if (!viz[i]) {
      Dfs(i);
      sol++;
    }
  cout << sol << "\n";
  return 0;
}
