#include <bits/stdc++.h>
using namespace std;
void sort(int n, int *a) {
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (a[j] > a[j + 1]) {
        int aux = a[j];
        a[j] = a[j + 1];
        a[j + 1] = aux;
      }
    }
  }
}
int main(void) {
  int n, m, a[101];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  int fin = 0, count;
  sort(n, a);
  for (int i = 0; i < n; i++) {
    count = 1;
    for (int j = i; j < n; j++) {
      if (i == j) continue;
      if (abs(a[i] - a[j]) <= m)
        count++;
      else
        break;
    }
    if (fin < count) fin = count;
  }
  cout << n - fin;
  return (0);
}
