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