#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int n, d, DP[maxn][maxn][maxn], a[maxn];
int dp(int i, int Min, int Max) {
  if (i == n) {
    if (Max - Min <= d) return 0;
    return (int)1e9;
  }
  int &ret = DP[i][Min][Max];
  if (~ret) return ret;
  ret = (int)1e9;
  ret = min(ret, dp(i + 1, min(Min, a[i]), max(Max, a[i])));
  ret = min(ret, dp(i + 1, Min, Max) + 1);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) cin >> a[i];
  memset(DP, -1, sizeof DP);
  cout << dp(0, 101, 0) << endl;
  return 0;
}
