#include <bits/stdc++.h>
using namespace std;
int i, j, k, mn, mx, l, t, n, x = 1, sm, cnt, fg, a[1000010];
char ch[1000010];
int gcd(int a, int b) {
  while (b > 0) {
    a %= b;
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return a;
}
int main() {
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (i = n - 1; i >= 1; i--) {
      if (a[i] > a[i + 1]) break;
    }
    printf("%d\n", i);
  }
  return 0;
}
