#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[200], n, d, ras[200][200], ans = 1000000;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 0;
    return 0;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ras[i][j] = abs(a[i] - a[j]);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (ras[i][j] <= d) {
        int an = 0;
        for (int di = i - 1; di >= 0; di--) {
          if (di < 0) {
            break;
          }
          if (a[di] != a[di - 1]) an++;
        }
        for (int dj = j + 1; dj < n; dj++) {
          if (dj > n - 1) {
            break;
          }
          if (a[dj] != a[dj - 1]) an++;
        }
        if (an < ans) {
          ans = an;
        }
      }
    }
  }
  if (ans == 1000000) ans = n - 1;
  cout << ans;
  return 0;
}
