a = input().split(' ')
n = int(a[0])
d = int(a[1])

a = input().split(' ')
a = [int(i) for i in a]
a.sort()

j=[]

for i in range(len(a)):
    for i2 in range(i,len(a)):
        if a[i2] - a[i] <= d :
            j.append(len(a)-(i2-i+1))

print(min(j))
