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