#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int inf = 1e18;
const long long int N = 200001;
int main() {
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long int pos[n];
  pos[0] = 0;
  for (long long int i = 1; i < n; i++) {
    if (arr[i] > arr[i - 1]) {
      pos[i] = pos[i - 1];
    } else {
      pos[i] = i;
    }
  }
  cout << pos[n - 1];
  return 0;
}
