#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, i, j, k;
  int a[110];
  int b[110];
  while (cin >> n >> d) {
    int k = 0;
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    if (n == 1)
      printf("0\n");
    else {
      sort(a, a + n);
      if (d == 0) {
        if (a[n - 1] - a[0] != 0)
          printf("%d\n", n - 1);
        else
          printf("0\n");
      } else if (a[n - 1] - a[0] < d)
        printf("0\n");
      else {
        for (i = 1; i < n; i++) {
          b[i - 1] = a[i] - a[i - 1];
        }
        for (i = 0; i < n - 1; i++) {
          j = i;
          int sum = 0, p = 0;
          while (sum < d) {
            sum += b[j];
            j++;
            p++;
          }
          if (p > k) k = p;
        }
        printf("%d\n", n - k - 1);
      }
    }
  }
  return 0;
}
