#include <bits/stdc++.h>
using namespace std;
int n, k, a[200010], m;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  m = 1;
  for (int i = 1; i <= n; i++)
    if (a[i] - k >= a[m]) m++;
  printf("%d\n", min(n / 2, m - 1));
  return 0;
}
