#include <bits/stdc++.h>
#pragma 03
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
namespace DSU {
class dsu {
  int n;

 public:
  dsu(int N);
  int *par;
  int findpar(int x);
  bool same(int a, int b);
  void join(int a, int b);
};
dsu::dsu(int N) {
  this->n = N;
  par = new int[n + 1];
  for (int i = 1; i < n + 1; ++i) {
    par[i] = i;
  }
}
int dsu::findpar(int x) {
  if (par[par[x]] == par[x])
    return par[x];
  else
    return par[x] = findpar(par[x]);
}
bool dsu::same(int a, int b) { return (findpar(a) == findpar(b)); }
void dsu::join(int a, int b) {
  int ha = findpar(a), hb = findpar(b);
  par[hb] = ha;
}
};  // namespace DSU
using namespace DSU;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  dsu g(n + 1);
  for (int i = 1; i < n + 1; ++i) {
    int a;
    cin >> a;
    g.join(a, i);
  }
  int root[n + 1];
  memset(root, 0, sizeof(root));
  for (int i = 1; i < n + 1; ++i) root[g.findpar(i)]++;
  int cnt = 0;
  for (int i = 1; i < n + 1; ++i)
    if (root[i] != 0) ++cnt;
  cout << cnt;
}
