x, y = map(int, input().split()) 
a=list(map(int,input().split()))
a.sort()
cnt=0
mx=0
val=0

for i in range(x): 
    for j in range(i,x):
    
        if (abs(a[i]-a[j]))<=y:
           
            cnt=cnt+1
           

            
    mx=max(cnt,mx)
    cnt=0

           
   
print(x-mx)
