#include <bits/stdc++.h>
using namespace std;
void init() {
  long long n, d;
  cin >> n >> d;
  vector<long long> a(n);
  for (long long &i : a) cin >> i;
  sort(a.begin(), a.end());
  long long mid = (n - 2) / 2;
  long long cur = n - 1, ans = 0;
  for (long long i = mid; i >= 0; i--) {
    if (a[i] + d <= a[cur]) {
      cur--;
      ans++;
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  init();
  return 0;
}
