#include <bits/stdc++.h>
using namespace std;
int a[105], n, d;
int dp[105][105];
int solve(int l, int r) {
  if (dp[l][r] != -1) return dp[l][r];
  if (l > r) return dp[l][r] = 0;
  if (a[r] - a[l] <= d) return dp[l][r] = 0;
  return dp[l][r] = 1 + min(solve(l + 1, r), solve(l, r - 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> d;
  for (int i = 0; i < 105; i++)
    for (int j = 0; j < 105; j++) dp[i][j] = -1;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cout << solve(0, n - 1) << endl;
  return 0;
}
