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

public class Amusement {
    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];
            st = new StringTokenizer(br.readLine(), " ");
            for (int i = 0; i < count; i++) {
                pole[i] = Integer.parseInt(st.nextToken());
            }

            int j;
            int old = pole[count-1];
            for (j = count - 2; j > 0; j--) {
                if(pole[j] >= old) {
                    break;
                }
                old = pole[j];
            }
            System.out.println(j+1);
        }

        br.close();
    }

    private class Pond {

    }
}
