n,d = [int(x) for x in input().split()]
a=[int(x) for x in input().split()]
c=[0 for i in range(102)]
for i in a:
    c[i]+=1;
sum1=[0 for i in range(500)]
for i in range(1,101):
    sum1[i] = sum(c[i-1:i+d])
print(n-max(sum1))