#include <bits/stdc++.h>
using namespace std;
int n, d;
int arr[105];
int dp[105][105];
int solve(int left, int right) {
  if (right <= left) return 0;
  if (dp[left][right] != -1) return dp[left][right];
  int val = arr[right] - arr[left];
  if (val <= d) {
    return dp[left][right] = solve(left + 1, right - 1);
  } else {
    return dp[left][right] =
               min(1 + solve(left + 1, right), 1 + solve(left, right - 1));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> d;
  for (int i = (1); i <= (n); ++i) cin >> arr[i];
  memset(dp, -1, sizeof(dp));
  sort(arr + 1, arr + 1 + n);
  cout << solve(1, n);
  return 0;
}
