#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 5;
int n;
int a[N];
vector<int> e[N];
int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void INIT() {}
int z;
bool check(int x) {
  for (int i = 1; i <= x; i++) {
    if (a[n - x + i] - a[i] < z) return false;
  }
  return true;
}
void solve() {
  INIT();
  cin >> z;
  for (int i = 1; i <= n; i++) cin >> (a[i]);
  sort(a + 1, a + 1 + n);
  int l = 0, r = n / 2;
  int ans;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << (ans) << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n) {
    solve();
  }
  return 0;
}
