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