n,d=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
temp=[]
for i in range(len(a)):
    count=0
    for j in range(i,len(a)):
        if (a[j]-a[i])<=d:
            count+=1
        else:
            break
    temp.append(count)
t=max(temp)
print(len(a)-t)

