#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[101], m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int cou = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = abs(arr[i] - arr[j]);
      if (a > m) {
        cou++;
        break;
        arr[i] = 0;
        arr[j] = 0;
      }
    }
  }
  if (cou == 0)
    cout << cou << endl;
  else
    cout << cou - 1 << endl;
}
