package top.actim.test09;
import java.util.Arrays;
import java.util.Scanner;
public class GLD {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
sort();
}
static void sort() {
int n = sc.nextInt();
int[] temp = new int[n];
int[] targ = new int[n];
for (int i = 0; i < temp.length; i++) {
temp[i] = sc.nextInt();
targ[i] = temp[i];
}
Arrays.sort(targ);
int p = n - 1;
int q = n - 1;
while (p >= 0 && q >= 0) {
if (temp[p] == targ[q]) {
p--;
q--;
} else {
while (p >= 0 && temp[p] != targ[q]) {
p--;
}
}
}
System.out.println(q + 1);
}
static void eleBalance() {
int[] ele = { sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt() };
int avg = (ele[0] + ele[1] + ele[2] + ele[3]) / 4;
int sub = 0;
int p = 0, q = avg;
while (p <= q) {
int i = (p + q) / 2;
sub = 0;
for (int j = 0; j < ele.length; j++) {
if (ele[j] > i) {
sub += ele[j] - i;
}
}
int count = 0;
for (int j = 0; j < ele.length; j++) {
if (ele[j] < i) {
count += (i - ele[j]) * 2;
}
}
if (sub == count) {
System.out.println(i * 4);
return;
} else if (sub > count) {
p = i + 1;
} else {
q = i - 1;
}
}
System.out.println(-1);
return;
}
static void dance() {
char[] tar = sc.nextLine().toCharArray();
char[] min = sc.nextLine().toCharArray();
int con = 0;
for (int i = 0; i < tar.length; i++) {
if (tar[i] == min[i]) {
con += 20;
} else {
con -= 10;
con = con < 0 ? 0 : con;
}
}
System.out.println(con);
}
}