#include <bits/stdc++.h>
using namespace std;
int a[100];
int n, d;
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int i = 0, j = n - 1;
  int t = 1;
  while ((a[j] - a[i]) > d) {
    if ((a[j] - a[j - t]) > (a[i + t] - a[i])) {
      j = j - t;
      t = 1;
    } else if ((a[j] - a[j - t]) < (a[i + t] - a[i])) {
      i = i + t;
      t = 1;
    } else
      t++;
  }
  cout << (i + n - 1 - j) << endl;
}
