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