#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
int main(){
  int N;cin >> N;
  int A[N];
  rep(i,N)cin >> A[i];
  int kekka = 0;
  rep(i,N)if(i+1 == A[A[i]-1])kekka++;
  cout << kekka/2  << endl;
}