#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int n, m, i, j, k, l, c = 0, v = 0, u = 0, a[1000001];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = n; i >= 1; i--) {
    c++;
    if (a[i] < a[i - 1]) {
      v++;
      printf("%d", n - c);
      break;
    }
  }
  if (v == 0) printf("0");
  return 0;
}
