n, d = map(int, input().split())
l = list(map(int, input().split()))
max = 0
for i in range(1, 101):
    cnt = 0
    for element in l:
        if element >= i and element <= i + d:
            cnt += 1
    if cnt > max:
        max = cnt
print(n - max)