#include <bits/stdc++.h>
using namespace std;
int n, z;
int arr[200009];
void solve() {
  sort(arr, arr + n);
  int ans = 0, j = n / 2;
  for (int i = 0; i < n / 2; i++) {
    if (j == n) break;
    while (j < n && ((arr[j] - arr[i]) < z)) j++;
    if (j == n) break;
    ans++, j++;
    ;
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> z;
  for (int i = 0; i < n; i++) cin >> arr[i];
  solve();
  return 0;
}
