#include <bits/stdc++.h>

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (auto &i : arr) cin >> i;
    
    if (n == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> dp(n, 1);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            if (arr[j] <= arr[i] && dp[j] + 1 > dp[i]) {
                dp[i] = dp[j] + 1;
            }
        }
    }

    int len = *max_element(dp.begin(), dp.end());
    int punish = n - len;
    cout << punish << endl;

    return 0;
}