#include <bits/stdc++.h>
const int MAXN = 100001;
int base[MAXN];
int a[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  int num = 0;
  bool done = false;
  for (int i = n - 1; i >= 1; --i) {
    if (a[i - 1] > a[i]) {
      done = true;
      ++num;
    } else if (done) {
      ++num;
    }
  }
  printf("%d\n", num);
  return 0;
}
