#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 7, mod = 1000000007;
long long int a[N], cnt, sum, mx;
vector<pair<pair<long long int, long long int>, long long int>> v;
priority_queue<long long int, vector<long long int>, greater<long long int>> pq;
long long int kk;
stack<char> st;
long long int vis[N];
map<pair<long long int, long long int>,
    vector<pair<long long int, long long int>>>
    mp;
map<pair<long long int, long long int>, long long int> pm;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int z = 0, n, m = 0, mn = 0, mx = 0, i = 0, x = 0, y = 0, k, j = 0,
                xx, yy;
  string s, r;
  char c;
  pair<long long int, long long int> p1, p2;
  p1 = p2 = {0, 0};
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = n - 1; i >= 0; i--) {
    if (i == 0) break;
    if (a[i] < a[i - 1]) break;
  }
  cout << i;
}
