#include <bits/stdc++.h>
using namespace std;
const int mn = 200005;
int a[mn];
bool vis[mn];
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 i = 1, j = (n / 2) + 1;
  int sum = 0;
  for (; i <= n; i++) {
    if (vis[i]) continue;
    while ((j <= n && a[j] - a[i] < m) || vis[j]) ++j;
    if (j <= n) ++sum, vis[j] = 1;
  }
  printf("%d\n", sum);
}
