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