#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, x;
  cin >> n >> x;
  vector<int64_t> a(n);
  for (int64_t i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int64_t r = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] - x >= a[r]) r++;
  }
  cout << min(r, n / 2);
}
