#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MD = 1e9;
const long long MAXN = (1 << 17);
const long long MAX2 = (1 << 20);
const long long BASE = 1e9;
const double EPS = 1e-7;
const double PI = acos(-1);
const long long VAL = 2100;
long long n, z;
long long a[1000006];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> z;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  long long ans = 0;
  long long ukaz = n / 2 + 1;
  for (long long i = 1; i <= n / 2; i++) {
    if (ukaz > n) {
      break;
    }
    bool br = false;
    while (a[ukaz] - a[i] < z) {
      ukaz++;
      if (ukaz > n) {
        br = true;
        break;
      }
    }
    if (br) {
      break;
    }
    ukaz++;
    ans++;
  }
  cout << ans << '\n';
}
