#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long i, j;
long long prime_flag[1000000];
void calculate_prime_flag() {
  prime_flag[0] = prime_flag[1] = 1;
  for (i = 2; i < 1000000; i++) {
    if (prime_flag[i] == 0) {
      for (j = i * i; j < 1000000; j += i) {
        prime_flag[j] = 1;
      }
    }
  }
}
using namespace std;
vector<string> v;
int LPS(char *str) {
  int n = strlen(str);
  int i, j, cl;
  int l[n][n];
  for (i = 0; i < n; i++) l[i][i] = 1;
  for (cl = 2; cl <= n; cl++) {
    for (i = 0; i < n - cl + 1; i++) {
      j = i + cl - 1;
      if (str[i] == str[j] && cl == 2)
        l[i][j] = 2;
      else if (str[i] == str[j])
        l[i][j] = l[i + 1][j - 1] + 2;
      else
        l[i][j] = max(l[i][j - 1], l[i + 1][j]);
    }
  }
  return l[0][n - 1];
}
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long x;
  vector<long long> a;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    a.push_back(x);
  }
  long long cnt = 1;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] > a[i - 1]) {
      cnt++;
    } else
      break;
  }
  cout << n - cnt << endl;
  return 0;
}
