#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<stack>
#include<queue>
#include<string.h>
#include<array>
#include<algorithm>
#include<cmath>
using namespace std;
#define ff first
#define ss second
#define endl '\n'
const int maxn = 5e5;
const long long oo = 1e18;
int maxq = 29;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin >> a[i];
}
int cur = 0;
int id = 0;
if(k < a[0]){
a[0] = k;
cur += 1;
id = 1;
}
vector<int> p(n, -1);
vector<int> dp(n, 1);
for(int i = 0; i < n; i++){
for(int j = 0; j < i; j++){
if(a[i] < a[j] || a[i] <= a[j] + k){
dp[i] = max(dp[i], dp[j] + 1);
p[i] = j;
}
}
}
set<int> lis;
int res = *max_element(dp.begin(), dp.end());
if(id == 1){
cout << res + 1;
}
else{
cout << n - res;
}
}