n,d=map(int,input().split())


a=list(map(int,input().split()))
count=[0 for i in range(102)]
for i in range(n):
    count[a[i]]+=1
sum2=[0 for i in range(200)]

for i in range(1,101):
    sum2[i]=sum(count[i-1:i+d])
max1=(0,0)
#print(sum2[:15])
for i in range(len(sum2)):
    if(max1[1]<sum2[i]):
        max1=(i,sum2[i])
print(n-max1[1])
#print(max1[0])
    
    

