#include <bits/stdc++.h>
using namespace std;
int n, d, ans = 128, x[128];
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; ++i) cin >> x[i];
  sort(x, x + n);
  for (int l = 0; l < n; ++l)
    for (int r = l; r < n; ++r)
      if (x[r] - x[l] <= d) ans = min(ans, l + n - 1 - r);
  cout << ans;
}
