#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, res = 0;
  int a[105], s[105];
  memset(s, 0, sizeof(s));
  scanf("%d%d", &n, &d);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (abs(a[i] - a[j]) <= d) s[i]++;
    }
    if (s[i] > res) res = s[i];
  }
  res = n - res - 1;
  printf("%d\n", res);
  return 0;
}
