#include <iostream>
using namespace std;

int main()
{
  int N;
  cin>>N;
  int a[N+1];
  for(int i=1; i<=N; i++) cin>>a[i];

  int answ = 0;

  for(int i=1; i<=N; i++)
   if(i == a[a[i]])
    answ++;

  cout<<answ/2;
  return 0;
}
