// Arup Guha
// 2/10/2024
// Solution to Kattis Problem: Messy Lists

import java.util.*;
import java.io.*;

public class messy {

	public static void main(String[] args) throws Exception {
	
		// Get n.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(stdin.readLine());
		
		// Read in the first list.
		int[] a = new int[n];
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		for (int i=0; i<n; i++) a[i] = Integer.parseInt(tok.nextToken());
		
		// Make a copy.
		int[] b = new int[n];
		for (int i=0; i<n; i++) b[i] = a[i];
		
		// Sort the first list.
		Arrays.sort(a);
		
		// Just count the # of items that are wrong.
		int res = 0;
		for (int i=0; i<n; i++)
			if (a[i] != b[i])
				res++;
			
		// Ta da!
		System.out.println(res);
	}
}