#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int n, d, a[maxn], l[maxn], r[maxn];
void init() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
void readdata() {
  scanf("%d%d", &n, &d);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
}
void left(int pos) {
  int i = pos;
  while (i > 0) {
    if (a[pos] - a[i - 1] <= d) {
      i--;
      l[pos] = i;
    } else
      break;
  }
}
void work() {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    l[i] = r[i] = i;
    left(i);
    if (i - l[i] > ans) ans = i - l[i];
  }
  printf("%d\n", n - ans - 1);
}
int main() {
  readdata();
  work();
  return 0;
}
