#include <bits/stdc++.h>
using namespace std;
int pos[101];
int n, d;
int main() {
  scanf("%d%d", &n, &d);
  memset(pos, 0, sizeof(pos));
  int member;
  for (int i = 0; i < n; i++) {
    scanf("%d", &member);
    pos[member]++;
  }
  int mina = 100;
  for (int i = 1; i <= 100; i++) {
    int cont = 0;
    for (int j = i; j <= min(i + d, 100); j++) cont += pos[j];
    mina = min(mina, n - cont);
  }
  printf("%d\n", mina);
  return 0;
}
