#include <bits/stdc++.h>
using namespace std;
int n, d;
int arr[200];
int inf = 0x7fffff;
priority_queue<int, vector<int>, greater<int> > que;
int main() {
  int i, j, k, ans, tot, tmp, temp1, temp2;
  cin >> n >> d;
  for (i = 1; i <= n; i++) cin >> arr[i];
  sort(arr + 1, arr + 1 + n);
  ans = 0;
  for (i = 1; i <= n; i++) {
    tot = 0;
    for (j = i; j <= n; j++)
      if (arr[j] - arr[i] <= d) tot++;
    if (tot > ans) ans = tot;
  }
  cout << n - ans << endl;
  return 0;
}
