#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 10;
int n, a[MAXN], c = -1;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] > a[i + 1]) c = i;
  }
  cout << c + 1 << endl;
}
