#include <bits/stdc++.h>
using namespace std;
int n, ar[200000], f[200000];
int main() {
  vector<int> ans;
  cin >> n;
  memset(f, 0, n);
  for (int i = 1; i <= n; i++) cin >> ar[i];
  int i = n;
  while (i > 1 && ar[i - 1] < ar[i]) {
    i--;
  }
  cout << i - 1 << endl;
  return 0;
}
