#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, greater<int> > q1, q2;
int x[200005];
int main() {
  int n, z, ans = 0;
  cin >> n >> z;
  for (int i = 0; i < n; i++) cin >> x[i];
  sort(x, x + n);
  int l1 = n >> 1;
  for (int i = 0; i < l1; i++) q1.push(x[i]);
  for (int i = l1; i < n; i++) q2.push(x[i]);
  while (!q2.empty()) {
    if (!q1.empty() && q2.top() - q1.top() >= z) {
      ans++;
      q1.pop();
      q2.pop();
    } else {
      q1.push(q2.top());
      q2.pop();
    }
  }
  cout << ans << endl;
}
