#include <bits/stdc++.h>
int main() {
  int n, left = -1, right, pos = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &right);
    if (left > right) pos = i;
    left = right;
  }
  printf("%d\n", pos);
  return 0;
}
