#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int ans = 0;
  int s = 1;
  for (int i = 1; i <= n; i++) {
    while (a[i] - a[s] > d && s < i) {
      ans = max(ans, i - s);
      s++;
    }
  }
  if (s != n) ans = max(ans, n - s + 1);
  cout << n - ans << endl;
  return 0;
}
