#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[500], d, i, kq1 = 0, kq2 = 0;
  cin >> n >> d;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  i = n;
  while ((a[i] - a[1]) > d) {
    i--;
    kq1++;
  }
  i = 1;
  while ((a[n] - a[i]) > d) {
    i++;
    kq2++;
  }
  cout << min(kq1, kq2);
  return 0;
}
