a=input().split()
a[1]=int(a[1])
b=input().split()
counter=0
maxLen=0
for i in range(len(b)):
    b[i]=int(b[i])
b.sort()
for i in range(0,len(b)):
    for j in range(i+1,len(b)):
        if(abs(b[i]-b[j])<=a[1]):
            if(abs(j-i)+1>maxLen):
                maxLen=abs(j-i)+1
print(len(b)-maxLen)
            


            