#include <bits/stdc++.h>
using namespace std;
long long power(int x, unsigned int y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y >>= 1;
    x *= x;
  }
  return res;
}
void solve() {
  int n, z;
  cin >> n >> z;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long long ans = 0;
  int i = 0, j = n / 2;
  while (j < n) {
    if (arr[j] != -1 && arr[i] != -1 && abs(arr[i] - arr[j]) >= z) {
      ans++;
      arr[i] = -1;
      arr[j] = -1;
    }
    if (arr[j] != -1)
      j++;
    else
      i++, j++;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
