#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "< P; struct myhash{ size_t operator()(const vi &v) const { hash hsh; size_t ret=0; for(int x:v){ ret ^= hsh(x); ret = ret ^ (ret<<13); ret = ret ^ (ret>>17); ret = ret ^ (ret<<5); } return ret; } }; int main(){ int n; int x; cin>>n>>x; if(n>=30){ puts("0"); return 0; } x++; typedef unordered_set ss; // factorize x with n numbers ss S; S.insert(vi(n,1)); for(int p=2;p*p<=x;p++){ while(x%p==0){ x/=p; ss nxt; for(const vi &X : S){ REP(i,n){ if(i>0 && X[i]==X[i-1])continue; vi add(n,0); int nw = X[i]*p; int it = 0; REP(j,n){ while(it==i)it++; if(it0 && X[i]==X[i-1])continue; vi add(n,0); int nw = X[i]*x; int it = 0; REP(j,n){ while(it==i)it++; if(it