#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 7;
int a[N];
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 l = 1, r = n;
  while (a[r] - a[l] > d) {
    if (a[r - 1] - a[l] <= a[r] - a[l + 1]) {
      r--;
    } else {
      l++;
    }
  }
  cout << n - (r - l + 1);
  return 0;
}
