#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, k, a[N];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("main.in", "r"))
    freopen("main.in", "r", stdin);
  else if (fopen("something"
                 ".inp",
                 "r"))
    freopen(
        "something"
        ".inp",
        "r", stdin),
        freopen(
            "something"
            ".out",
            "w", stdout);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int j = n / 2 + 1, res = 0;
  for (int i = 1; i <= n / 2; i++) {
    while (j <= n && a[j] - a[i] < k) j++;
    if (a[j] - a[i] >= k) {
      res++;
      j++;
    }
  }
  cout << res << '\n';
  return 0;
}
