#include <bits/stdc++.h>
using namespace std;
long long a[200005];
multiset<long long> st;
multiset<long long>::iterator it;
int main() {
  long long n, x, z;
  scanf("%lld", &n), scanf("%lld", &z);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a + 1, a + n + 1);
  long long ans = 0;
  for (long long i = n / 2 + 1; i <= n; i++) {
    st.insert(a[i]);
  }
  for (long long i = 1; i <= n / 2; i++) {
    it = st.lower_bound(a[i] + z);
    if (it != st.end()) {
      st.erase(it);
      ans++;
    }
  }
  printf("%lld\n", ans);
}
