#include <bits/stdc++.h>
using namespace std;
vector<long long> tree;
void build(vector<long long> &arr, long long ind, long long l, long long r) {
  if (l == r) {
    tree[ind] = arr[l];
    return;
  }
  long long mid = (l + r) / 2;
  build(arr, ind * 2, l, mid);
  build(arr, ind * 2 + 1, mid + 1, r);
  tree[ind] = max(tree[ind * 2], tree[ind * 2 + 1]);
}
long long getMax(long long ind, long long tl, long long tr, long long l,
                 long long r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return tree[ind];
  long long tm = (tl + tr) / 2;
  long long a = getMax(ind * 2, tl, tm, l, min(r, tm));
  long long b = getMax(ind * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
  return max(a, b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long count = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] < a[i + 1]) {
      count++;
    } else {
      break;
    }
  }
  cout << n - count;
  return 0;
}
