#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n; cin >> n;
vector<int> a(n);
for(int i=0;i<n;++i) {
cin >> a[i];
}
int x=1;
for(int i=n-2; i>=0; --i) {
if(a[i+1]>a[i]) ++x;
else break;
}
cout << n - x << "\n";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCWludCBuOyBjaW4gPj4gbjsKICAgIHZlY3RvcjxpbnQ+IGEobik7IAogICAgZm9yKGludCBpPTA7aTxuOysraSkgewogICAgICAgIGNpbiA+PiBhW2ldOwogICAgfQogICAgaW50IHg9MTsKICAgIGZvcihpbnQgaT1uLTI7IGk+PTA7IC0taSkgewogICAgICAgIGlmKGFbaSsxXT5hW2ldKSArK3g7CiAgICAgICAgZWxzZSBicmVhazsKICAgIH0KICAgIGNvdXQgPDwgbiAtIHggPDwgIlxuIjsKCXJldHVybiAwOwp9