#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[500], d, i, j, kq = 0;
  cin >> n >> d;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (i = 1; i < n; i++)
    for (j = i + 1; j <= n; j++)
      if ((a[j] - a[i]) <= d) kq = max(kq, j - i + 1);
  cout << n - kq;
  return 0;
}
