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