#include <bits/stdc++.h>
using namespace std;
long long n, a[300000], k, s, d, x, y;
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  k = n - 1;
  for (int i = 0; i < n; i++) {
    for (int j = i; j <= k; j++) {
      if (a[k] - a[j] > d) x++;
      if (a[j] - a[i] > d) y++;
    }
    if (x == 0 && y == 0) continue;
    if (y >= x) {
      s++;
    } else {
      s++;
      k--;
      i--;
    }
    x = 0;
    y = 0;
  }
  cout << s;
  return 0;
}
