#include <bits/stdc++.h>
using namespace std;
long long n, z, cnt;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> z;
  int arr[n + 5];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = n - 1, j = (n / 2) - 1; i >= n / 2 && j >= 0; j--)
    if (arr[i] - arr[j] >= z) cnt++, i--;
  cout << cnt << endl;
  return 0;
}
