read=lambda:map(int,input().split())
n,d=read()
x=sorted(list(read()))
p=1
for i in range(n):
    m=1
    for j in range(i+1,n):
        if x[j]-x[i]>d:
            break
        m+=1
    p=max(p,m)
print(n-p)