#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
}
