n,d=map(int,input().split())
x=sorted(list(map(int,input().split(" "))))
sum=0
list=[]
for i in range(n):
    for j in range(i,n):
        if x[j]-x[i]<=d:
            sum+=1
    list.append(sum)
    sum=0    
print(len(x)-max(list))        