n, d = [int(k) for k in input().split(' ') if k]
f = sorted([int(k) for k in input().split(' ') if k])
pairs = [[] for i in range(n + 1)]
bad = 0
for a in range(n):
    for b in range(a, n):
        if f[b] - f[a] > d:
            pairs[a].append(b)
            pairs[b].append(a)
            bad += 1
count = 0
while bad > 0:
    maximum = 0
    where = -1
    for i in range(len(pairs)):
        if maximum < len(pairs[i]):
            maximum = len(pairs[i])
            where = i
    count += 1
    bad -= maximum
    for i in range(len(pairs)):
        if where in pairs[i]:
            del pairs[i][pairs[i].index(where)]
    pairs[where] = []
print(count)
