n,d =[int(i) for i in input().split()]
e=[int(i) for i in input().split()]
g=[]
for i in range(n):
    g.append(min(e))
    e[e.index(min(e))]=1232345
w=23456
for i in range(n):
    c=0
    h=0
    t=g[i]
    for z in range(n):
        if z >= i:
            c=g[z]
        if c-t <= d:
            h+=1
    if w > h:
        w=h
print(n-w)