n,d = map(int,input().split(' '))
x = input().split(' ')
x = [int(i) for i in x]
x = sorted(x)
i = 0
count = 0
j = n-1
if n == 1:
    print(0)
while x[j]-x[i]>d:
    if x[i+1]-x[i]>x[j]-x[j-1]:
        i+=1
    else:
        j-=1
    count+=1
print(count)