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