#include <bits/stdc++.h>
using namespace std;
vector<long long> mas;
int max() {
  int max = -9999999;
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i] > max) max = mas[i];
  }
  return max;
}
int min() {
  int min = 9999999;
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i] < min) min = mas[i];
  }
  return min;
}
int num(int a) {
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i] == a) return i;
  }
}
int predmin(int a) {
  int min = 9999999;
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i] < min && mas[i] != a) min = mas[i];
  }
  return min;
}
int predmax(int a) {
  int max = -9999999;
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i] > max && mas[i] != a) max = mas[i];
  }
  return max;
}
bool is(int a, int n) {
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i] == a && i != n) return true;
  }
  return false;
}
int main() {
  int n = 0, d = 0, buff = 0, dell = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> buff;
    mas.push_back(buff);
  }
  while (max() - min() > d) {
    if (predmax(max()) - min() < max() - predmin(min()))
      mas.erase(mas.begin() + num(max()));
    else if (predmax(max()) - min() == max() - predmin(min())) {
      if (is(max(), num(max())))
        mas.erase(mas.begin() + num(min()));
      else
        mas.erase(mas.begin() + num(max()));
    } else
      mas.erase(mas.begin() + num(min()));
    dell++;
  }
  cout << dell << endl;
  return 0;
}
