#include <bits/stdc++.h>
using namespace std;
int n, x, ar[1000];
int main() {
  while (cin >> n >> x) {
    int indx[1000], mx = -1;
    for (int i = 0; i < n; i++) scanf("%d", ar + i);
    sort(ar, ar + n);
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++)
        if (ar[j] - ar[i] <= x) mx = max(mx, j - i + 1);
    cout << n - mx << endl;
  }
  return 0;
}
