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