#include <bits/stdc++.h>
using namespace std;
void shomoy() {}
bool isprime(int n) {
  int f;
  for (f = 2; f * f <= n; f++) {
    if (n % f == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio();
  cin.tie(0);
  long long i, n, count = 0, max, index;
  max = 0;
  cin >> n;
  index = n;
  long long arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] > max) {
      max = arr[i];
    }
  }
  for (i = 0; i < n; i++) {
    if (arr[i + 1] < arr[i]) {
      index = i + 1;
      break;
    }
  }
  cout << n - index << "\n";
  return 0;
}
