#include <bits/stdc++.h>
using namespace std;
const int maxn = 128;
int a[maxn], n, m, head, tail, ans = 99999999;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  for (int i = n; i > 0; i--) {
    for (int j = 1; j <= i; j++) {
      if (a[i] - a[j] <= m) ans = min(ans, n - i + j - 1);
    }
  }
  printf("%d", ans);
  return 0;
}
