n, d =list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a.append(0)
ans = n+1
if(max(a)-min(a)<=d):
    print(0)
else:
    for i in range(n):
        for j in range(n+1):
            na = a[i:j]
            if(len(na)>0)and(max(na)-min(na)<=d):
                ans = min(ans, i + n - j)
    print(ans)
