#include <bits/stdc++.h>
using namespace std;
int n, a[100100];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int c = 1;
  for (int i = n - 1; i > 0; i--) {
    if (a[i] < a[i + 1])
      c++;
    else
      break;
  }
  cout << (n - c) << endl;
  return 0;
}
