#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
const long long _inf = -1e16;
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
long long addmod(long long& a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
long long submod(long long& a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
long long a[100010];
long long b[100010];
int main() {
  long long n, i, cnt = 0, idx = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  b[n] = a[n];
  for (i = 1; i < n; i++) {
    if (a[i] > a[i + 1]) idx = i;
  }
  cout << idx << endl;
  return 0;
}
