#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int array[n];
  for (int i = 0; i < n; i++) cin >> array[i];
  int count = n - 1;
  for (int i = n - 2; array[i] < array[i + 1]; i--) {
    count--;
  }
  cout << count;
}
