import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Monsters {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        String line;
        while ((line = br.readLine()) != null) {
            int count = Integer.parseInt(line);
            int[] pole = new int[count+1];
            st = new StringTokenizer(br.readLine(), " ");
            for (int i = 1; i <= count; i++) {
                pole[i] = Integer.parseInt(st.nextToken());
            }

            int swaps = 0;
            for (int i = 1; i <= count; i++) {
                while (pole[i] != i) {
                    int a = pole[i];
                    int temp = pole[a];
                    pole[a] = pole[i];
                    pole[i] = temp;
                    swaps++;
                }
            }

            System.out.println(swaps);
        }

        br.close();
    }
}
