n,dmax=input().split()
A=list(map(int,input().split()))
count=0
d=int(max(A)-min(A))
while d>int(dmax):
    if sorted(A)[-2]-min(A)<=max(A)-sorted(A)[1]:
        A.remove(max(A))
        d=max(A)-min(A)
        count+=1
    else:
        A.remove(min(A))
        d=max(A)-min(A)
        count+=1
print(count)