#include <bits/stdc++.h>
int n, m, ans, a[105];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  std::sort(a + 1, a + 1 + n);
  ans = 1e9;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++)
      if (a[j] - a[i] <= m && n - (j - i + 1) < ans) ans = n - (j - i + 1);
  printf("%d\n", ans);
}
