a,b=map(int,input().split())
c=list(map(int,input().split()))
d=sorted(c)
e=0
for _ in range(a):
    for i in range(a):
        if(_<i):
            if(d[i]-d[_]<=b):
                e=max(e,i-_)

print(a-e-1)