#include <bits/stdc++.h>
using namespace std;
double const pi = 3.1415926536;
int const N = 1000005;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] < a[i - 1]) {
      ans = i;
      break;
    }
  }
  cout << ans;
}
