#include <bits/stdc++.h>
int gcd(int a, int b) {
  int r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
void sort(long long a[], long long len) {
  int i, j, temp;
  for (i = 0; i < len - 1; i++)
    for (j = 0; j < len - 1 - i; j++)
      if (a[j] > a[j + 1]) {
        temp = a[j];
        a[j] = a[j + 1];
        a[j + 1] = temp;
      }
}
int main() {
  long long int n, d, dots[100], i, orin, head = 0, ttl = 0;
  scanf("%lld %lld", &n, &d);
  orin = n;
  for (i = 0; i < n; i++) scanf("%lld", &dots[i]);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  sort(dots, n);
  int j;
  for (i = n - 1; i >= 0; i--) {
    for (j = 0; i + j < n; j++) {
      if (dots[i + j] - dots[j] <= d) {
        printf("%lld\n", n - i - 1);
        return 0;
      }
    }
  }
  printf("%lld\n", ttl);
  return 0;
}
