#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int a[maxn];
int n, z;
bool check(int pos) {
  if (n % 2 != 0 && pos >= (n + 1) / 2) return false;
  if (n % 2 == 0 && pos > n / 2) return false;
  for (int i = 1; i <= pos; i++) {
    if (a[n - pos + i] - a[i] >= z) continue;
    return false;
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &z);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  int l = 0, r = (n >> 1), ans = 0;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid)) {
      l = mid + 1;
      ans = mid;
    } else
      r = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}
