s = input().split()
n = int(s[0])
d = int(s[1])
s = input().split()
cl = []
mn = 100
for i in s:
    cl.append(int(i))

cl = sorted(cl)
if cl[n-1]-cl[0]<=d or n==1:
    print(0)
else:
    count1 = 0
    count2 = 0
    i = 0
    while(i<=n-1 and cl[i]-cl[0]<=d):
        i+=1
    count1 = n-i
    i = n-1
    while(i>=0 and cl[n-1]-cl[i]<=d):
        i-=1
    count2 = i+1

    if count1>count2:
        print(count2)
    else:
        print(count1)