#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  int a[100010];
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = n; i >= 1; i--)
    if (a[i] < a[i - 1]) break;
  if (i == 0)
    cout << "0";
  else
    cout << i - 1;
}
