#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int t, n, m, x = 0, y = 0, flag = 0, cnt = 0, sum = 0, sum1 = 0, sum0 = 0,
               flag1 = 0;
  int a1, a2, a3, b1, b2, b3;
  vector<int> d;
  cin >> t;
  int a[t];
  for (int i = 0; i < t; i++) {
    cin >> a[i];
  }
  x = t - 1;
  while (x > 0 && a[x - 1] < a[x]) {
    x--;
  }
  cout << x << "\n";
  return 0;
}
