#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 1, MINX = 1, MAXX = 100;
int a[MAXN];
int min(int x, int y) {
  if (x < y)
    return x;
  else
    return y;
}
int main() {
  int n, d;
  while (scanf("%d %d", &n, &d) != -1) {
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    int ans = n;
    for (int i = 0; i <= 100; i++) {
      int del = 0;
      for (int j = 1; j <= n; j++)
        if (a[j] < i || a[j] > i + d) del++;
      ans = min(ans, del);
    }
    cout << ans;
  }
  return 0;
}
