#include <bits/stdc++.h>
using namespace std;
long long int a, c[1000001], d, e = 0, f, i, j, l, max1 = -999999999;
int main() {
  cin >> a;
  for (i = 0; i < a; i++) {
    cin >> c[i];
  }
  for (i = a - 1; i > 0; i--) {
    if (c[i] > c[i - 1])
      e++;
    else
      break;
  }
  e++;
  cout << a - e << endl;
  return 0;
}
