#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  long nnn;
  cin >> nnn;
  long *arr = new long[nnn];
  for (long i = 0; i < nnn; ++i) cin >> arr[i];
  long nn = 0;
  for (long i = nnn - 2; i >= 0; --i)
    if (arr[i] < arr[i + 1])
      ++nn;
    else
      break;
  ++nn;
  cout << nnn - nn << endl;
  return 0;
}
