n,d=map(int,input().split())
s=list(map(int,input().split()))
s.sort()

sol=-1
for i in range(n):
    for j in range(i,n):
        if(s[j]-s[i]<=d):
            if(j-i)>sol:
                sol=j-i
print(n-sol-1)
