#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int points[n];
  for (int i = 0; i < n; i++) cin >> points[i];
  sort(points, points + n);
  int diff[n - 1];
  for (int i = 0; i < n - 1; i++) diff[i] = points[i + 1] - points[i];
  int diameter = points[n - 1] - points[0];
  int solutions[n][n];
  int k = 0;
  for (; k < n - 1; k++) {
    for (int i = k, j = 0; i >= 0; i--, j++) {
      if (i == 0) {
        if (j == 0)
          solutions[i][j] = diameter;
        else
          solutions[i][j] = solutions[i][j - 1] - diff[n - 1 - j];
      } else {
        solutions[i][j] = solutions[i - 1][j] - diff[i - 1];
      }
      if (solutions[i][j] <= d) {
        cout << k;
        return 0;
      }
    }
  }
  cout << k;
  return 0;
}
