#include <bits/stdc++.h>
using namespace std;
int all[101];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) {
    cin >> all[i];
  }
  sort(all, all + n);
  int pos1 = 0, pos2 = n - 1;
  int result = 0;
  for (int i = 0; i < n && all[pos2] - all[pos1] > d; ++i) {
    int cnt1 = 0, cnt2 = 0;
    for (int j = pos1; j <= pos2; ++j) {
      if (all[j] - all[pos1] > d) cnt1++;
      if (all[pos2] - all[j] > d) cnt2++;
    }
    if (cnt1 > cnt2)
      pos1++;
    else
      pos2--;
    result++;
  }
  cout << result << endl;
  return 0;
}
