#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int m = n - 1;
  while (m) {
    if (a[m] > a[m - 1])
      m--;
    else
      break;
  }
  printf("%d\n", m);
  return 0;
}
