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