#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, z;
  cin >> n >> z;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  std::queue<int> Q;
  for (int i = n / 2; i < n; ++i) Q.push(a[i]);
  int cnt = 0;
  for (int i = 0; i < n / 2; ++i) {
    while (!Q.empty() && Q.front() - a[i] < z) Q.pop();
    if (!Q.empty()) {
      Q.pop();
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
