#include <bits/stdc++.h>
using namespace std;
int n, k, a[105];
int main() {
  int i, j, res = INT_MAX;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++)
    for (j = i; j <= n; j++)
      if (a[j] - a[i] <= k) res = min(n - (j - i + 1), res);
  cout << res;
  return 0;
}
