n,dmax=input().split()
A=list(map(int,input().split()))
B=[int(i) for i in A]
maxhetzelfde=1
for i in range(0,int(n)):
    aantalhetzelfde=1
    for j in range(1,int(n)):
        if int(A[i])==int(A[j]) and int(i)!=int(j):
            aantalhetzelfde+=1
    if aantalhetzelfde>maxhetzelfde:
        maxhetzelfde=aantalhetzelfde
count=0
d=int(max(A)-min(A))
while d>int(dmax):
    A.remove(max(A))
    d=max(A)-min(A)
    count+=1
if count>int(len(B)-maxhetzelfde):
    print(int(len(B)-maxhetzelfde))
else:
    print(count)