n,m=map(int,raw_input().strip().split())
l=map(int,raw_input().strip().split())
l.sort()
count=0
max1=0
for i in range(n):
    count=0
    for j in range(i,n):
        if l[j]-l[i]>m:
            break
        else:
            count=count+1
    if count>max1:
        max1=count
print n-max1