str1=input()
str2=input()
a=str1.split(" ")
b=str2.split(" ")
n=int(a[0])
d=int(a[1])
multiset=[]
for i in b:
    multiset.append(int(i))
num=[]
num.append(1)
for i in range(1,n):
    j=i-1
    num.append(1)
    while (j>=0 and abs(multiset[i]-multiset[j])<=d):
        num[i]+=1
        j-=1
print(n-max(num))