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