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