#include <bits/stdc++.h>
using namespace std;
vector<long long int> v, v1, v2;
multiset<long long int> mss;
multiset<long long int>::iterator it;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, d, i, j, z = 0, k, w = 1, q = 0, cnt = 0, x = 0, p = 0;
  cin >> a >> c;
  for (i = 0; i < a; i++) {
    cin >> b;
    v.push_back(b);
  }
  sort(v.begin(), v.end());
  for (i = 0; i < a / 2; i++) {
    v1.push_back(v[i]);
  }
  for (j = i; j < a; j++) {
    mss.insert(v[j]);
  }
  for (i = 0; i < v1.size(); i++) {
    d = v1[i] + c;
    it = mss.lower_bound(d);
    if (it == mss.end()) {
      break;
    }
    cnt++;
    mss.erase(it);
  }
  cout << cnt;
  return 0;
}
