#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e2 + 5;
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 + n + 1);
  int maxx = -1;
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    for (int j = i; j <= n && a[j] - a[i] <= d; j++) temp++;
    maxx = max(maxx, temp);
  }
  cout << n - maxx << endl;
  return 0;
}
