n, d = [int(i) for i in raw_input().split()]
p = [int(i) for i in raw_input().split()]
p.sort()
c = 0
if (n == 1):
    print 0
else:
    while ((p[-1] - p[0]) > d):
        if ((p[1] -  p[0]) > (p[-1] - p[-2])):
            del p[0]
        else:
            del p[-1]
        c += 1
    print c
