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