#include <bits/stdc++.h>
using namespace std;
void print(vector<char> ar) {
  for (long long i = 0; i < ar.size(); i++) cout << ar[i];
  cout << "\n";
}
void rprint(vector<long long> ar) {
  for (long long i = ar.size() - 1; i >= 0; i--) cout << ar[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, z;
    cin >> n >> z;
    long long ar[n];
    for (long long i = 0; i < n; i++) cin >> ar[i];
    sort(ar, ar + n);
    long long r = n - 1;
    long long ans = 0;
    for (long long i = n / 2 - 1; i >= 0; i--) {
      if (ar[r] - ar[i] >= z) {
        ans++;
        r--;
      }
    }
    cout << ans << "\n";
  }
}
