#include <bits/stdc++.h>
using namespace std;
int N, Z;
int main() {
  scanf("%d%d", &N, &Z);
  vector<int> arr(N);
  for (auto &i : arr) {
    scanf("%d", &i);
  }
  sort(arr.begin(), arr.end());
  int beg = 0;
  int mid = arr.size() / 2;
  int c = mid;
  int cnt = 0;
  while (beg < c && mid < arr.size()) {
    if (abs(arr[beg] - arr[mid]) >= Z) {
      ++cnt;
      ++beg;
      ++mid;
    } else {
      while (mid < arr.size() && abs(arr[beg] - arr[mid]) < Z) {
        ++mid;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
