#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n), v(n);
  for (long long int i = 0; i <= n - 1; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  long long int i = n - 1;
  while (i - 1 >= 0) {
    if (a[i - 1] <= a[i])
      i--;
    else
      break;
  }
  cout << i << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1, test = 0;
  while (t--) {
    solve();
  }
}
