#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n;
int x[N];
int check(int l, int r);
int main() {
  int d;
  scanf("%d%d", &n, &d);
  for (int i = 1; i <= n; ++i) scanf("%d", &x[i]);
  sort(x + 1, x + n + 1);
  int ans = n;
  for (int i = 1; i <= n; ++i) ans = min(ans, check(x[i], x[i] + d));
  printf("%d\n", ans);
  return 0;
}
int check(int l, int r) {
  int ret = 0;
  for (int i = 1; i <= n; ++i)
    if (x[i] < l || x[i] > r) ++ret;
  return ret;
}
