#include <bits/stdc++.h>
using namespace std;
long long a[211000];
long long n, z;
int main() {
  long long ans = 0;
  cin >> n >> z;
  for (register int i = (0); i < (n); i++) cin >> a[i];
  sort(a, a + n);
  int ptr1 = 0, ptr2 = n / 2;
  while (ptr1 < n / 2 && ptr2 < n)
    if (a[ptr2] - a[ptr1] >= z)
      ans++, ptr1++, ptr2++;
    else if (ptr2 == n || ptr1 == n / 2)
      break;
    else
      ptr2++;
  cout << ans;
  return ~~(0 ^ 0 ^ 0);
}
