n,d=map(int,input().split())
a=list(map(int,input().split()))
c=[]
a=sorted(a)
for i in range(len(a)):
    b=0
    for j in range(i+1,len(a)):
        if a[j]-a[i]<=d:
            b=b+1
    b=b+1
    c.append(n-b)
print(min(c))
    
            
            
    

    
