#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
int n, z;
int a[maxn];
bool check(int k) {
  for (int i = 1; i <= k; i++) {
    if (a[n - k + i] - a[i] < z) return false;
  }
  return true;
}
int main() {
  cin >> n >> z;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int l = 1, r = n / 2, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  cout << ans << "\n";
  return 0;
}
