#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  int n = 0;
  cin >> n;
  int *a;
  a = new int[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int lenght = 1;
  for (i = n - 2; a[i] < a[i + 1] && i != -1; i--) {
    lenght++;
  }
  cout << n - lenght << endl;
  delete a;
  return 0;
}
