n,d=tuple(int(x) for x in input().split())
multiset=[int(x) for x in input().split()]

multiset.sort()
local_ans=0
ans=1e9+7
for i in range(len(multiset)):
    for j in range(i+1,len(multiset)):
        if abs(multiset[i]-multiset[j])>d:
            local_ans=len(multiset)-j+i
            break
    else:
        local_ans=i
    if local_ans<ans:
        ans=local_ans
print(ans)