#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100010],b=0;
  cin>>n;
  for(int i=0;i<n;++i)cin>>a[i];
  for(int i=0;i<n;++i){
    if(i+1==a[a[i]-1])b++;
  }
  cout << b/2 << endl;
  return 0;
}