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