n,d = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
#print (a)
l = 0
k = a[-1]-a[0]
while k>d:
    if a[1]-a[0] > a[n-1]-a[n-2]:
        a.remove(a[0])
    else:
        a.remove(a[-1])
    k = a[-1] - a[0]
    #print (a)
    l += 1
    n -= 1
print (l)