#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K, arr[10005], counT, L, R, temp, temp1;
  scanf("%lld %lld", &N, &K);
  for (long long i = 0; i < N; i++) scanf("%lld", &arr[i]);
  sort(arr, arr + N);
  L = 0, R = N - 1;
  counT = 0;
  for (long long i = 0; i < N; i++) {
    if (i > N - 1 - i) break;
    if (arr[N - 1 - i] - arr[i] <= K) break;
    if (arr[R] - arr[L + 1] <= K) {
      counT++;
      break;
    } else {
      temp = arr[R] - arr[L + 1];
    }
    if (arr[R - 1] - arr[L] <= K) {
      counT++;
      break;
    } else {
      temp1 = arr[R - 1] - arr[L];
    }
    if (temp < temp1)
      L++;
    else
      R--;
    counT += 2;
    ;
    if (temp == temp1) counT--;
  }
  printf("%lld\n", counT);
  return 0;
}
