#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, d;
  while (cin >> n >> d) {
    int x[105];
    for (int i = 0; i < n; ++i) {
      cin >> x[i];
    }
    sort(x, x + n);
    int maxn = -100;
    for (int j = 0; j < n; ++j) {
      for (int i = j; i < n; ++i) {
        int as = x[i] - x[j];
        int sb = i - j + 1;
        if (as > d) break;
        if (sb > maxn) maxn = sb;
      }
    }
    if (maxn == -100) maxn = n;
    cout << n - maxn << endl;
  }
  return 0;
}
