#include <bits/stdc++.h>
using namespace std;
double pi = 3.1415926536;
const int oo = (int)1e9;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int di[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[] = {1, -1, 0, 0, 1, -1, 1, -1};
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> myvec(n);
  int mn = oo;
  for (int i = 0; i < n; i++) {
    cin >> myvec[i];
  }
  int counter = 0, ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (myvec[i] > myvec[i + 1]) {
      ans += counter;
      ans++;
      counter = 0;
    } else
      counter++;
  }
  cout << ans;
}
