#include <bits/stdc++.h>
using namespace std;
int arr[100002];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; ++i) cin >> arr[i];
  int res = n - 1;
  while (res > 0 && arr[res - 1] < arr[res]) --res;
  cout << res << "\n";
  return 0;
}
