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