#include <bits/stdc++.h>
using namespace std;
int n, z, ans;
int a[200500];
multiset<int> s;
int main() {
  scanf("%d%d", &n, &z);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  for (int i = n / 2 + 1; i <= n; i++) s.insert(a[i]);
  for (int i = 1; i <= n / 2; i++) {
    auto it = s.lower_bound(a[i] + z);
    if (it != s.end()) s.erase(it), ans++;
  }
  printf("%d\n", ans);
  return 0;
}
