require'prime' n,x=gets.split.map &:to_i a=(x+1).prime_division.map{|k,v|(0..v).map{|i|k**i}} b=a.shift.product(*a).map{|e|e.reduce :*}.sort[1..-1].reverse m={} f=->x,n,d,a{ return 1 if x==1&&n==0 return 0 if x==1||n==0 m[[x,n,d]]||=(d...a.size).reduce(0){|r,i|x%a[i]>0?r:r+f[x/a[i],n-1,i,a]} } p f[x+1,n,0,b]