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