n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
res = n - 1
for i in range(n):
    for j in range(i, n):
        if l[j] - l[i] > k:
            continue
        res = min(res, n - (j - i + 1))
print(res)
