#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, z;
  cin >> n >> z;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<bool> vis(n);
  int ans = 0;
  int st = 0, end = n / 2;
  while (st < n / 2 && end < n) {
    if (a[end] - a[st] >= z) {
      ans++;
      st++;
      end++;
    } else {
      end++;
    }
  }
  cout << ans;
  return 0;
}
