
list_points = [0]*101

numbers = list(map(int, input().split()))
n = numbers[0]
d = numbers[1]
points = list(map(int, input().split()))

for point in points:
    list_points[point] += 1

max_count = 0
count = 0
for i in range(0,d+1):
    count = count + list_points[i]
max_count = count
for i in range(d+1,101):
    count += list_points[i]
    count -= list_points[i-d-1]
    if count > max_count:
        max_count = count
ans = n - max_count
print(ans)