#include <bits/stdc++.h>
using namespace std;
int memo[100][100];
void init() {
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) memo[i][j] = -1;
  }
}
int solve(vector<int> &v, int sp, int ep, int d) {
  if (sp >= ep) return 0;
  if ((v[ep] - v[sp]) <= d) return 0;
  if (memo[sp][ep] != -1)
    return memo[sp][ep];
  else {
    memo[sp][ep] =
        min((1 + solve(v, sp + 1, ep, d)), (1 + solve(v, sp, ep - 1, d)));
    return memo[sp][ep];
  }
}
int main() {
  int n, d, cd;
  cin >> n >> d;
  vector<int> v(n);
  init();
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << solve(v, 0, n - 1, d);
  return 0;
}
