#include <bits/stdc++.h>
using namespace std;
const int MAXN = 202030;
int n, k, arr[MAXN];
bool check(int mid) {
  for (int i = 1; i <= mid; i++)
    if (arr[n - mid + i] - arr[i] < k) return 0;
  return 1;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  sort(arr + 1, arr + 1 + n);
  int L = 0, R = n >> 1, mid, ans = 0;
  while (L <= R) {
    mid = (L + R) >> 1;
    if (check(mid))
      ans = mid, L = mid + 1;
    else
      R = mid - 1;
  }
  printf("%d\n", ans);
}
