#include<iostream>
using namespace std;
int a[100005];
int main() {
int n; cin >> n;
for(int i = 0; i < n; i++) {
cin >> a[i];
}
int i = n-1;
while(i > 0 && a[i-1] < a[i]) {
i--;
}
cout << i << endl;
}
I2luY2x1ZGU8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGFbMTAwMDA1XTsKCmludCBtYWluKCkgewogICAgaW50IG47IGNpbiA+PiBuOwoJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgewoJCWNpbiA+PiBhW2ldOwoJfQoJaW50IGkgPSBuLTE7Cgl3aGlsZShpID4gMCAmJiBhW2ktMV0gPCBhW2ldKSB7CgkJaS0tOwoJfQoJY291dCA8PCBpIDw8IGVuZGw7Cn0K