#include <bits/stdc++.h>
using namespace std;
int n, m, t;
bool l;
vector<int> v;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> m, v.push_back(m);
  for (int i = n - 1; i > 0; i--) {
    if (v[i] < v[i - 1]) {
      cout << i;
      return 0;
    }
  }
  cout << 0;
  return 0;
}
