#include <bits/stdc++.h>
using namespace std;
long long n, m, z, ans;
long long a[1000005];
bool p[1000005];
void rd() {
  cin >> n >> z;
  for (long long i = 1; i <= n; i++) cin >> a[i];
}
signed main() {
  rd();
  sort(a + 1, a + n + 1);
  long long j = n >> 1;
  for (long long i = n; i >= 1; i--)
    if (!p[i]) {
      while ((a[i] - a[j] < z || p[j]) && j >= 1) j--;
      if (j >= 1) {
        ans++;
        p[j] = 1;
        j--;
      }
    }
  cout << ans;
  return 0;
}
