#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, a[101];
  cin >> n >> d;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  int res = 1e9;
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (a[j] - a[i] <= d) {
        res = min(res, n - (j - i + 1));
      }
    }
  }
  cout << res;
  return 0;
}
