#include <bits/stdc++.h>
template <class T>
inline void swap(T &x, T &y) {
  T tmp = x;
  x = y, y = tmp;
}
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), c = ch;
  while (ch < '0' || ch > '9') c = ch, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  if (c == '-') x = -x;
}
const int INF = 0x3f3f3f3f;
const int MAXN = 100 + 10;
int n, d, num[MAXN];
int main() {
  read(n), read(d);
  for (int i = 1; i <= n; ++i) read(num[i]);
  std::sort(num + 1, num + 1 + n);
  int l = 1, r = n, ans = 0;
  while (l <= r) {
    int tmp1 = r, tmp2;
    while (num[tmp1] - num[l] > d) --tmp1;
    tmp2 = r - tmp1;
    int tmp3 = l, tmp4;
    while (num[r] - num[tmp3] > d) ++tmp3;
    tmp4 = tmp3 - l;
    if (tmp2 == 0 && tmp4 == 0) break;
    if (tmp2 >= tmp4)
      ++l;
    else
      --r;
    ++ans;
  }
  printf("%d", ans);
  return 0;
}
