#include <bits/stdc++.h>
int main() {
  int s[100001], m, n, t[100001], min, ans = 0;
  scanf("%d", &n);
  for (m = 0; m < n; m++) {
    scanf("%d", &s[m]);
  }
  for (m = n - 1; m > 0; m--) {
    if (s[m - 1] > s[m]) break;
  }
  printf("%d\n", m);
}
