n , d = [int(c) for c in input().split()]
a=[0]
b = [int(x) for x in input().split()]
for i in b:
    a.append(i)
a.sort()
ans=10**9
for i in range(1,n+1):
    now = n-1
    for j in range(i+1,n+1):
        if(a[j]-a[i]<=d):
            now-=1
    ans= min(ans,now)
print(ans)
