#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[105], x = 0, y = 0;
  cin >> n >> m;
  if (n != 0) {
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] - a[0] > m)
        x++;
      else
        break;
    }
    for (int i = 0; i < n; i++) {
      if (a[n - 1] - a[i] > m)
        y++;
      else
        break;
    }
    if (x <= y)
      cout << x << endl;
    else
      cout << y << endl;
  }
}
