#include <bits/stdc++.h>
int main() {
  int i;
  int n;
  int th[100010];
  th[0] = 9000000;
  scanf("%d", &n);
  n++;
  for (i = 1; i < n; i++) {
    scanf("%d", &th[i]);
  }
  for (i = n - 2; th[i] < th[i + 1]; i--) {
  }
  printf("%d\n", i);
}
