// Arup Guha
// 12/27/2017
// Solution to 2017 Dec USACO Silver Problem: The Bovine Shuffle

import java.util.*;
import java.io.*;

public class shuffle {

	public static int n;
	public static int[] forward;
	public static int[] status;

	public static void main(String[] args) throws Exception {

		// Read in the forwarding array.
		BufferedReader stdin = new BufferedReader(new FileReader("shuffle.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		tok = new StringTokenizer(stdin.readLine());
		forward = new int[n];
		for (int i=0; i<n; i++)
			forward[i] = Integer.parseInt(tok.nextToken())-1;

		// Store the status (0 = not visited, 1 = visited, no cycle, 2 = visited, cycle)
		status = new int[n];

		// Go through each.
		for (int i=0; i<n; i++)
			if (status[i] == 0)
				go(i);

		// Count items in a cycle.
		int res = 0;
		for (int i=0; i<n; i++)
			if (status[i] == 2)
				res++;

		// Ta da!
		PrintWriter out = new PrintWriter(new FileWriter("shuffle.out"));
		out.println(res);
		out.close();
		stdin.close();
	}

	public static void go(int i) {

		HashSet<Integer> used = new HashSet<Integer>();

		// Loop till get to a non-unused item.
		while (status[i] == 0) {
			used.add(i);
			status[i] = 1;
			i = forward[i];
		}

		// Cycle detected - mark all.
		if (used.contains(i)) {
			int savei = i;
			do {
				status[i] = 2;
				i = forward[i];
			} while (i != savei);
		}
	}
}