n, d = (int(x) for x in input().split())
elems = [int(x) for x in input().split()]
ans = 101
for l in range(0, 101):
    r = l + d
    outside = 0
    for elem in elems:
        if elem < l or elem > r:
            outside += 1
    ans = min(ans, outside)
print(ans)