#include <bits/stdc++.h>
using namespace std;
int cut(int n, int d, int i, int j, vector<int>& res) {
  if (res[j] - res[i] <= d) return n + i - j - 1;
  if (j == i + 1) return n - 1;
  int p1 = res[i + 1] - res[i], p2 = res[j] - res[j - 1];
  if (p1 > p2)
    return cut(n, d, i + 1, j, res);
  else
    return cut(n, d, i, j - 1, res);
}
int main() {
  int n = 0, d = 0;
  cin >> n;
  cin >> d;
  vector<int> res(n, 0);
  int i = 0;
  while (i < n) cin >> res[i++];
  sort(res.begin(), res.end());
  cout << cut(n, d, 0, n - 1, res) << endl;
  return 0;
}
