#include <bits/stdc++.h>
const int N = 100;
int n, d, aa[N + 10], ans;
int main() {
  scanf("%d%d", &n, &d);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), aa[x]++;
  for (int i = 1; i <= N; i++) aa[i] += aa[i - 1];
  if (d == N) ans = n;
  for (int i = d + 1; i <= N; i++) ans = std::max(ans, aa[i] - aa[i - d - 1]);
  printf("%d\n", n - ans);
  return 0;
}
