#include <bits/stdc++.h>
int main() {
  int i, j, a[100000], n, count = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = n - 1, j = n - 2; j >= 0; j--, i--)
    if (a[j] < a[i])
      count++;
    else
      break;
  if (count == 0)
    printf("%d", n - 1);
  else
    printf("%d", n - count - 1);
  return 0;
}
