#include <bits/stdc++.h>
using namespace std;
int dp[102][102];
int min_d(int i, int j, int arr[], int n, int d) {
  if (i == j) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  if (arr[j] - arr[i] > d)
    return (dp[i][j] = 1 + min(min_d(i + 1, j, arr, n, d),
                               min_d(i, j - 1, arr, n, d)));
  return (dp[i][j] = 0);
}
int main() {
  int n, d;
  cin >> n >> d;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < 102; i++)
    for (int j = 0; j < 102; j++) dp[i][j] = -1;
  int i = 0, j = n - 1;
  cout << min_d(i, j, arr, n, d) << endl;
  return 0;
}
