R=lambda:map(int,raw_input().split())
n,d=R()
a=sorted(R())
v=0
j=0
print(a[0])
for i in range(n):
     
     while a[i]-a[j]>d:
          j+=1
          print("ij",j,i-j+1)
     v=max(v,i-j+1)
print(n-v)