#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r;
} k[10005];
int main() {
  int n, d;
  while (~scanf("%d%d", &n, &d)) {
    int a[105], p = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j <= n; j++) {
        int m = a[j] - a[i];
        if (m <= d) {
          p++;
          k[p].l = a[i];
          k[p].r = a[j];
        }
      }
    }
    int maxx = 0;
    for (int i = 1; i <= p; i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        if (a[j] >= k[i].l && a[j] <= k[i].r) sum++;
      }
      if (sum >= maxx) maxx = sum;
    }
    printf("%d\n", n - maxx);
  }
  return 0;
}
