#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int a[maxn];
int main(int argc, char *argv[]) {
  int n, z, ans = 0;
  scanf("%d%d", &n, &z);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = n / 2 + n % 2; i < n; i++)
    if (a[i] - z >= a[ans]) ans++;
  ;
  printf("%d\n", ans);
  return 0;
}
