#include <bits/stdc++.h>
int n, d, cnt, ans = 0x7fffffff, a[105];
int main() {
  scanf("%d%d", &n, &d);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) {
    cnt = 0;
    for (int j = 0; j < n; j++)
      if (a[j] < a[i] || a[j] - a[i] > d) cnt++;
    if (cnt < ans) ans = cnt;
  }
  printf("%d", ans);
}
