#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100010];
  if (0) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  };
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int dem = 1;
  int i = n;
  while (i > 1 && a[i] > a[i - 1]) {
    dem++;
    i--;
  }
  printf("%d", n - dem);
  return 0;
}
