#include <bits/stdc++.h>
using namespace std;
int v[110];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) cin >> v[i];
  sort(v, v + n);
  int ans = 0, ans2 = 0;
  int p = 0;
  while (abs(v[p] - v[n - 1]) > d and p < n) p++, ans++;
  p = n - 1;
  while (abs(v[p] - v[0]) > d and p >= 0) p--, ans2++;
  cout << min(ans, ans2) << "\n";
  return 0;
}
