#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10;
bool matched[MAXN];
int n, z;
int x[MAXN];
bool check(int k) {
  for (int i = 0; i < k; ++i)
    if (x[n - k + i] - x[i] < z) return false;
  return true;
}
int main(void) {
  scanf("%d%d", &n, &z);
  for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
  sort(x, x + n);
  int lo = 0, hi = n / 2;
  while (lo < hi) {
    int mid = (lo + hi) / 2 + 1;
    if (check(mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  printf("%d\n", lo);
  return 0;
}
