#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  while (cin >> n >> d) {
    int num[110];
    int Max = -9999;
    for (int i = 0; i < n; i++) cin >> num[i];
    sort(num, num + n);
    for (int i = 0; i < n; i++) {
      int temp = 1;
      for (int j = i + 1; j < n; j++) {
        if (num[j] - num[i] <= d)
          temp++;
        else
          break;
      }
      Max = max(temp, Max);
    }
    cout << n - Max << endl;
  }
}
