#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, z;
int a[maxn];
int main() {
  scanf("%d%d", &n, &z);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  int l = 0, r = n / 2 + 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    bool flag = true;
    for (int i = 0; i < mid; i++) {
      flag &= a[n - mid + i] - a[i] >= z;
    }
    if (flag)
      l = mid;
    else
      r = mid;
  }
  printf("%d\n", l);
  return 0;
}
