ans = []
n,x=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
for i in range(n):
    for j in range(i,n):
        if arr[j]-arr[i]==x:
            ans.append(j-i)
if len(ans)==0:
    print(0)
else:
    print (n-max(ans)-1)
