#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

ll chondoco(vector<int> a) {
    vector<ll> dp(a.size(), 1);

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

    int maxl = *max_element(dp.begin(), dp.end());

    return a.size() - maxl;
}

int n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    freopen("CAU4.INP", "r", stdin);
    freopen("CAU4.OUT", "w", stdout);
    cin >> n;

    vector<int> a(n);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll res = chondoco(a);
    cout <<  res << endl;

    return 0;
}
