#include <bits/stdc++.h>
using namespace std;
int s[105];
bool p[105];
int main() {
  int n, i, d, a, ans = 0, MAX = 0;
  scanf("%d%d", &n, &d);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    s[a]++;
    p[a] = 1;
    MAX = max(MAX, a);
  }
  for (i = 2; i <= MAX; i++) s[i] += s[i - 1];
  for (i = d + 1; i <= MAX; i++)
    if (p[i] == 1) ans = max(ans, s[i] - s[i - d - 1]);
  printf("%d", n - ans);
  return 0;
}
