n,d=[int(i) for  i in input().split()]
l=[int(i) for i in input().split()]
l.sort()
mymap={}
max=0
for i in range(n):
    sol=1
    x=l[i]
    for j in range(n):
        if j!=i and abs(x-l[j])<=d and l[j]>=x:
            sol+=1
    if sol>max:
        max=sol
print(n-max)
            
