n,d = list(map(int, input().split()))
x = list(map(int, input().split()))

t = [0] * 102

for i in x:
    t[i]+=1

mn = n
for i in range(100):
    # i -- i+d
    cnt = 0
    for j in range(i, min(101, i+d+1)):
        cnt += t[j]
    if n-cnt < mn:
        mn = n-cnt

print(mn)
