#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = (int)1e6 + 7, mod = 1000000007, M = 2e9;
int n, c, a[107], d;
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    for (int j = i; a[j] - a[i] <= d && j < n; j++) c = max(c, j - i + 1);
  }
  cout << n - c;
  return 0;
}
