import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int []a = new int[N]; for(int i = 0; i < N; i++) { a[i] = scan.nextInt(); } scan.close(); int k = N; int cnt = 0; for(int i = N - 1; i >= 0; i--) { if(a[i] == k) { k--; }else { cnt++; } } System.out.println(cnt); } }