#include <bits/stdc++.h>
using namespace std;
const int maxn = 150;
int main() {
  int n, d, a[maxn], ans = 1e9;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (a[j] - a[i] <= d) ans = min(ans, i - 1 + n - j);
    }
  }
  cout << ans << endl;
}
