#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, z, j = 0, k = 0;
  cin >> n >> z;
  int arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  vector<int> v1, v2;
  for (i = 0; i < n / 2; i++) {
    v1.push_back(arr[i]);
  }
  for (i = n / 2; i < n; i++) {
    v2.push_back(arr[i]);
    k++;
  }
  int in = 0, sum = 0;
  for (i = 0; i < k; i++) {
    if (v2[i] - v1[in] >= z) {
      sum++;
      in++;
      if (in == n / 2) break;
    }
  }
  cout << sum;
  return 0;
}
