#include <bits/stdc++.h>
using namespace std;
int rn = 0;
int a[105];
int tm[105];
void setrk(int n) {
  rn = n;
  int idx = 1;
  sort(a + 1, a + 1 + rn);
  for (int i = 2; i <= rn; ++i)
    if (a[i] != a[i - 1]) a[++idx] = a[i];
  rn = idx;
}
int main() {
  int n, d;
  cin >> n >> d;
  a[0] = 0;
  tm[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    tm[a[i]]++;
  }
  setrk(n);
  int mi = 0;
  int t = 0;
  for (int i = 1; i <= rn; i++) {
    t = tm[a[i]];
    for (int j = i + 1; j <= rn; j++) {
      if (a[j] <= a[i] + d) t += tm[a[j]];
    }
    mi = max(mi, t);
  }
  cout << n - mi << endl;
}
