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