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

ans=1e9+7
local_ans=0
for x in multiset:
    for y in multiset:
        if abs(x-y) > d:
            local_ans+=1
    if local_ans<ans:
        ans=local_ans

print(ans)