#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ls = 0;
  bool first = 0, f = 0;
  cin >> n;
  int Arr[n];
  long long int cnt = 0;
  for (int i = 0; i < n; i++) cin >> Arr[i];
  for (int i = 1; i < n; i++)
    if (Arr[i] < Arr[i - 1]) cnt = i;
  cout << cnt;
}
