#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const long long INF = 0x3f3f3f3f3f3f3f3f;
inline long long readll() {
  long long x(0), op(1);
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') op = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * op;
}
const int sz = 3e5 + 9;
long long a[sz], n, k;
int getbests() { return n / 2; }
int solve(int s) {
  int cur = s;
  int ans = 0;
  for (int i = 0; i < s; ++i) {
    while (cur < n && a[cur] - a[i] < k) cur++;
    if (cur >= n) break;
    if (a[cur] - a[i] >= k) ans++;
    cur++;
  }
  return ans;
}
int main() {
  n = readll(), k = readll();
  for (int i = 0; i < n; ++i) a[i] = readll();
  sort(a, a + n);
  int s = getbests();
  int ans = solve(s);
  cout << ans << endl;
  return 0;
}
