#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  while (cin >> n >> d) {
    int a[200];
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1) {
      printf("0\n");
      continue;
    }
    sort(a, a + n);
    int num, ans = 0;
    for (int i = 0; i < n - 1; i++) {
      num = 1;
      for (int j = i + 1; j < n; j++) {
        if (a[j] - a[i] <= d)
          num++;
        else
          break;
      }
      ans = max(num, ans);
    }
    printf("%d\n", n - ans);
  }
  return 0;
}
