d=[] f=->x,n,i{n<2?$.+=1: i.upto(d.size-1){|i|d[i]**n>x||x%d[i]>0||f[x/d[i],n-1,i]}} eval'N,X='+gets.split*?,+'+1' 2.upto(X**0.5){|i|d|=[i,X/i]if X%i<1} d=d.sort f[X,N,0]; p$.-1