#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, a[101], b[101], i, j;
  cin >> n >> d;
  for (int i = 0; i < 101; i++) b[i] = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  i = 0;
  j = 0;
  while (j < n) {
    while ((j < n) && (a[j] - a[i] <= d)) j++;
    b[i] = j - i - 1;
    i++;
  }
  cout << n - 1 - *max_element(b, b + n);
  return 0;
}
