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

ls = list(map(int, input().split()))
ref = 101
count = 0

for i in ls:
    max = i
    for j in ls:
        if i >= j and i - j <= d:
            count = 0
            for k in ls:
                if k < j or k > i:
                    count += 1
            if count < ref:
                ref = count

print(ref)