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