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