#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, a, ans = 0, temp = 0;
  cin >> n;
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    cin >> a;
    if (temp > a) {
      ans = i - 1;
    }
    temp = a;
  }
  cout << ans;
  return 0;
}
