#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int num[maxn];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> num[i];
  sort(num, num + n);
  int MAX = 0;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (num[j] - num[i] > d) {
        flag = true;
        int ans = j - 1 - i + 1;
        MAX = max(MAX, ans);
        break;
      }
    }
  }
  if (!flag)
    cout << 0 << endl;
  else
    cout << n - MAX << endl;
}
