n, d = raw_input().split()
l = raw_input().split()
l = [int(i) for i in l]
l = sorted(l)

def minrem(l, d):
    if len(l) == 1: return 0
    if l[-1] - l[0] <= d: return 0
    else: return 1 + min(minrem(l[1:], d), minrem(l[:-1], d))

print minrem(l, d)