#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
inline int read() {
  int c = getchar(), fg = 1, sum = 0;
  while (c < '0' || c > '9') {
    if (c == '-') fg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') sum = sum * 10 + c - '0', c = getchar();
  return sum * fg;
}
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
int a[105];
int main() {
  int n = read(), d = read();
  int mx = 0;
  for (int i = 1; i <= n; ++i) {
    int x = read();
    a[x]++;
    mx++;
  }
  int ans = 10000;
  for (int i = 1; i + d <= 100; ++i) {
    int cnt = 0;
    for (int j = i; j - i <= d; ++j) cnt += a[j];
    ans = min(ans, mx - cnt);
  }
  printf("%d\n", ans);
  return 0;
}
