#include <bits/stdc++.h>
using namespace std;
int A[101];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) cin >> A[i];
  sort(A, A + n);
  int ans = 1e9;
  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 << endl;
  return 0;
}
