#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, z;
  scanf("%d%d", &n, &z);
  int x[n];
  for (int i = 0; i < n; i++) scanf("%d", x + i);
  sort(x, x + n);
  int fst = (n - 2) / 2;
  int i = n - 1;
  int ans = 0;
  for (; fst >= 0 and i >= n / 2; fst--) {
    if (x[fst] + z <= x[i]) {
      i--;
      ans++;
    }
  }
  cout << ans << "\n";
}
