eval"N,M,X,*A="+`dd`.split*?, p A.sort!.bsearch{|y|b=A[...q=A.index(y)]+A[q+1..];(N-3).downto(i=0).count{|j|i+=1while i=b[i]+b[j];i