#include <bits/stdc++.h>
using namespace std;
const int maxn = 200050;
int a[maxn];
int n, m;
void solve() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int l = 1, r = n / 2 + 1, sum = 0;
  while (l <= n / 2 && r <= n) {
    if (a[r] - a[l] >= m) {
      l++;
      r++;
      sum++;
    } else
      r++;
  }
  printf("%d\n", sum);
}
int main() {
  solve();
  return 0;
}
