#include <bits/stdc++.h>
using namespace std;
int n, d, m = 100;
int tab[105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> tab[i];
  }
  sort(tab, tab + n);
  for (int i = 0; i < n; i++) {
    int licz;
    for (int j = i + 1; j < n; j++) {
      licz = i;
      if (tab[j] - tab[i] > d) {
        licz += n - j;
        break;
      }
    }
    if (licz < m) m = licz;
  }
  cout << m << "\n";
  return 0;
}
