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