#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int sum = 1;
  for (int i = n - 1; i > 0; i--) {
    if (a[i] > a[i + 1]) break;
    sum++;
  }
  printf("%d\n", n - sum);
  return 0;
}
