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

multiset.sort()
ans=1e9+7
local_ans=0
i=0
j=len(multiset)-1
while(j>=i):
    if multiset[j]-multiset[i]<=d:
        print(local_ans)
        break
    elif abs(multiset[j]-multiset[i+1])<=d:
        local_ans+=1
        print(local_ans)
        break;
    elif abs(multiset[j-1]-multiset[i])<=d:
        local_ans+=1
        print(local_ans)
        break
    else:
        i+=1
        j-=1
        local_ans+=2
        