#include <bits/stdc++.h>
using namespace std;
int n, d;
int a[105];
int Max;
void getnum(int p, int q) {
  if (q == n) return;
  if (a[p] + d >= a[q]) {
    Max = std::max(Max, q - p);
    q++;
  } else
    p++;
  getnum(p, q);
  return;
}
int main() {
  scanf("%d %d", &n, &d);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  std::sort(a, a + n);
  getnum(0, 1);
  printf("%d", n - Max - 1);
}
