#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, z;
  cin >> n >> z;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  int l = 0;
  while (l < n && x[l] - x[0] < z) {
    l++;
  }
  if (l == n) {
    cout << 0 << endl;
    return 0;
  }
  int k = 1;
  for (k = 1; k < n / 2; k++) {
    l++;
    while (l < n && x[l] - x[k] < z) {
      l++;
    }
    if (l == n) break;
  }
  cout << k << endl;
  return 0;
}
