#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, d, a[101], ans = N * 10000;
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= i; j--) {
      if (a[j] - a[i] <= d) ans = min(ans, n - j + i - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
