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