#include <bits/stdc++.h>
using namespace std;
int ar[101];
int main() {
  int i, n, a, b, d;
  cin >> n >> d;
  for (i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n);
  i = b = 0;
  n--;
  while (ar[n] - ar[i] > d && n > i) {
    if (ar[n - 1] - ar[i] <= d) {
      ++b;
      break;
    }
    if (ar[n] - ar[i + 1] <= d) {
      ++b;
      break;
    }
    n--;
    i++;
    b += 2;
  }
  cout << b << endl;
  return 0;
}
