#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int x, temp, c = -1;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (i != 1) {
      if (temp > x) c = i;
    }
    temp = x;
  }
  if (c == -1) c = 1;
  cout << c - 1 << endl;
  return 0;
}
