#include <bits/stdc++.h>
using namespace std;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void free() {
  freopen("A.in", "r", stdin);
  freopen("A.out", "w", stdout);
}
int a[101];
int main() {
  boost();
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = n - 1;
  for (int i = 0; i < n; i++) {
    int cnt = i;
    for (int j = i; j < n; j++)
      if (a[i] != a[j] && a[j] - a[i] > d) cnt++;
    ans = min(cnt, ans);
  }
  cout << ans, exit(0);
}
