#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> v, u;
  pair<long long, long long> n;
  set<string> y;
  long long a, b, c, d = 0, e = 1, i, f = 0, g = 0, j, k = 0, l = 0, r = 0, z,
                     m, h, p[100001];
  string t, s, x, q;
  double w;
  cin >> a;
  for (i = 1; i <= a; i++) {
    cin >> p[i];
  }
  while (a > 1 && p[a - 1] < p[a]) {
    a--;
  }
  cout << a - 1;
}
