#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int a[102];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < 1; i++) {
    for (int j = n - 1; j >= i + 1; j--) {
      if (abs(a[j] - a[i]) > d && a[j] != -100) {
        cnt++;
        a[j] = -100;
      }
    }
  }
  cout << cnt;
  return 0;
}
