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