#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, z, l, r, ans = 0;
  cin >> n >> z;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  l = 0, r = n / 2 + n % 2;
  while (r < n) {
    if (a[r] - a[l] >= z)
      ans++, r++, l++;
    else
      r++;
  }
  cout << ans << '\n';
  return 0;
}
