#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int Mess[100001];
  int Counter = 0;
  for (int i = 0; i < n; i++) {
    cin >> Mess[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == 0) {
      cout << i << endl;
      break;
    }
    if (Mess[i] < Mess[i - 1]) {
      if (i == n - 1) {
        Counter = n - 1;
        cout << i << endl;
        break;
      }
      if (i != n - 1) {
        Counter = n - (i + 1);
        cout << i << endl;
        break;
      }
    }
  }
}
