#include <bits/stdc++.h>
using namespace std;
int main(){
int n; // declare n to be a number
cin>>n; // read n from the input
// declare "books" to be a sequence of numbers of length n:
vector<int> books(n);
for(int i=0;i<n;i=i+1)
cin>>books[i]; // read books from the input
// declare current to be a sequence of numbers of length n+1;
// initially, all elements are 0
vector<int> current(n,0);
int result=1; // declare result to be a number which is initially 1
for(int i=0;i<n;i=i+1){ // for each i from 0 to n in turn
result=max(result,current[i]);
for(int j=0;j<i;j=j+1){ // for each j from 0 to i-1 in turn
// if the number of the book at position i is larger
// than the number of the book at position j:
if(books[i]>books[j]){
// if current at position [i] is smaller
// than current at position j
if(current[i]<current[j]+1){
// update current at position i to current at position j:
current[i]=current[j]+1;
}
}
}
}
cout<<n-result<<'\n'; // write n-result to the output
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpewoJaW50IG47IC8vIGRlY2xhcmUgbiB0byBiZSBhIG51bWJlcgoJY2luPj5uOyAvLyByZWFkIG4gZnJvbSB0aGUgaW5wdXQKCS8vIGRlY2xhcmUgImJvb2tzIiB0byBiZSBhIHNlcXVlbmNlIG9mIG51bWJlcnMgb2YgbGVuZ3RoIG46Cgl2ZWN0b3I8aW50PiBib29rcyhuKTsKCWZvcihpbnQgaT0wO2k8bjtpPWkrMSkKCQljaW4+PmJvb2tzW2ldOyAvLyByZWFkIGJvb2tzIGZyb20gdGhlIGlucHV0CgkvLyBkZWNsYXJlIGN1cnJlbnQgdG8gYmUgYSBzZXF1ZW5jZSBvZiBudW1iZXJzIG9mIGxlbmd0aCBuKzE7CgkvLyBpbml0aWFsbHksIGFsbCBlbGVtZW50cyBhcmUgMAoJdmVjdG9yPGludD4gY3VycmVudChuLDApOwoJaW50IHJlc3VsdD0xOyAvLyBkZWNsYXJlIHJlc3VsdCB0byBiZSBhIG51bWJlciB3aGljaCBpcyBpbml0aWFsbHkgMQoJZm9yKGludCBpPTA7aTxuO2k9aSsxKXs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