n, d = map(int, input().split())
n = input().split()
for i in range(len(n)):
    n[i] = int(n[i])

n.sort()

r = 0
d2 = 0

for i in range(len(n)):
    for j in range(len(n)):
        d2 = n[j] - n[i]
        if d2 <= d and j - i + 1 > r:
            r = j - i + 1
print(len(n) - r)
