n, d =list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
n = 0
while(max(a)-min(a)>d):
    if len(a)>2:
        if(a[1]-a[0]>a[-1]-a[-2]):
            a = a[1:]
        else:
            a = a[:-1]
    else:
        a = a[0]
    n += 1
print(n)
