n, d = map(int, input().split())
c, p = [0] * 102, [0] * 102
for x in map(int, input().split()):
    c[x] += 1
for i in range(1, 102):
    p[i] = p[i - 1] + c[i]
#print(p)
print(n - max(p[i + d + 1] - p[i] for i in range(101 - d)))