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