#include <bits/stdc++.h>
using namespace std;
vector<long long> readvec(long long length, long long off = 0);
template <typename T>
string ts(T v);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  long long z;
  cin >> n >> z;
  vector<long long> v = readvec(n);
  sort(v.begin(), v.end());
  long long left = 0;
  long long right = v.size() / 2;
  long long ans = 0;
  while (true) {
    if (left >= v.size() / 2 || right >= v.size()) break;
    if (v[right] - v[left] >= z) {
      ans++;
      left++;
      right++;
    } else {
      right++;
    }
  }
  cout << ans << endl;
}
template <typename T>
string ts(T v) {
  stringstream ss;
  ss << "[";
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) ss << ", ";
    ss << *it;
  }
  ss << "]";
  return ss.str();
}
vector<long long> readvec(long long length, long long off) {
  vector<long long> v;
  for (long long i = 0; i < length; i++) {
    long long x;
    cin >> x;
    v.push_back(x + off);
  }
  return v;
}
