#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, s = INT_MAX, d;
  int a[500];
  scanf("%d %d", &n, &d);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int dd = a[n - 1] - a[0];
  if (dd <= d) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 1; i < n; i++) {
    if (a[n - 1] - a[i] <= d) {
      s = i;
      dd = a[n - 1] - a[i];
      break;
    }
  }
  int ss = INT_MAX;
  int c = 0;
  for (j = n - 2; j >= 0; j--) {
    c++;
    if (abs(a[j] - a[0]) <= d) {
      ss = min(ss, c);
      dd = a[j] - a[0];
      break;
    }
  }
  cout << min(s, ss) << endl;
  return 0;
}
