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