#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int xChange[] = {0, 1, 0, -1};
int yChange[] = {1, 0, -1, 0};
const int N = (int)1e5 + 5;
int a[N], n, ans;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int idx = 0;
  for (int i = n - 1; i >= 0; i--) {
    idx = i;
    if (a[i] < a[i - 1]) break;
  }
  cout << idx;
  return 0;
}
