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