n,d=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*101;su=[]
for i in a:
    b[i]+=1
for i in range(1,100-d+1):
    su.append(sum(b[i:i+d+1]))
if len(su)==0:
    print(0)
else:print(n-max(su))