#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
long long n, z;
long long arr[1014159];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> z;
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  arr[n + 1] = MOD * MOD;
  sort(arr + 1, arr + 1 + n);
  long long ans = 0;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  long long ixd = 1;
  for (long long i = 1; i <= n / 2; i++) {
    auto c = lower_bound(arr + ixd + 1, arr + n + 1, arr[i] + z);
    ixd = c - arr;
    if (*c == MOD * MOD) break;
    if (ixd < n + 1) ans++;
    ;
  }
  cout << ans;
  return 0;
}
