#include <bits/stdc++.h>
using namespace std;
int n, d, ans;
int a[105], f[105];
bool vis[105];
int main() {
  scanf("%d%d", &n, &d);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int s = 1, e = 1, sum = 1;
  while (s <= e && e <= n) {
    while (a[e] - a[s] > d) {
      s++;
      sum--;
    }
    ans = max(ans, sum);
    sum++, e++;
  }
  printf("%d", n - ans);
}
