#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 200;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (a[j] - a[i] <= d) {
        ans = min(ans, n - j + i - 1);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
