#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a = 0, b, maxi = -1;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> b;
    if (b < a) maxi = i - 1;
    a = b;
  }
  cout << maxi + 1;
  return 0;
}
