#include <bits/stdc++.h>
using namespace std;
queue<long long> vals;
long long x[200001];
bool taken[200001];
int main() {
  int n;
  long long z;
  cin >> n >> z;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  sort(x + 1, x + n + 1);
  int res = 0;
  int l = 0, r = n / 2;
  while (l <= r) {
    int m = (l + r) / 2;
    bool can = true;
    for (int i = 1; i <= m; i++) {
      if (x[n - m + i] - x[i] < z) can = false;
    }
    if (can) {
      res = max(res, m);
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  cout << res << '\n';
}
