n, d = list(map(int, input().split()))

x = sorted(map(int, input().split()))
max_num = 1

for i in range(len(x)):
    flag = True
    for j in range(i + 1, len(x)):
        if x[j] - x[i] > d:
            if j - i > max_num:
                max_num = j - i
            flag = False
            break
    if flag:
        if len(x) - i > max_num:
            max_num = len(x) - i

print(len(x) - max_num)



