/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		int[] arr={1,3,2,3,2,4,2};
		int c=0;
		int LHS=0;
		HashMap<Integer,Integer>m=new HashMap<>();
		for(int i=0;i<arr.length;i++){
			LHS=arr[arr[arr[i]]];
			if(m.containsKey(LHS)){
				c++;
			}else{
				m.put(LHS,m.getOrDefault(LHS,0)+1);
			}
		}
		System.out.print(c);
	}
}