def D(a):
    return a[-1]-a[0]
    
n,d=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()
m=1000
for i in range(0,n):
    for j in range(i,n):
        if D(a[i:j+1])<=d:
            m=min(m,n-len(a[i:j+1]))
print(m)