/*
F[i][j]表示以i开头的长度为j的有几个
F[i][j]=f[i+1][j-1]+f[i+2][j-1]+...+f[maxx][j-1]
但这样做会超时
观察到:
f[i+1][j]=f[i+2][j-1]+...+f[maxx][j-1]
F[i][j]=f[i+1][j-1]+f[i+1][j]
*/
/*90分超时代码*/
#include<iostream>
#include<cstdio>
#include<cstring>
#define LL unsigned long long
#define maxn 30010
using namespace std;
int p,w,r,l,len=1;
int a[maxn],f[15];
struct node
{
int l,a[210];
}g[520][610],ans;
void add(node &x,node &y)
{
int l1=x.l,l2=y.l,l3=1,i,j,k;
LL c[210]={0};
while(l3<=l1||l3<=l2)
{
c[l3]+=(x.a[l3]+y.a[l3]);
c[l3+1]+=c[l3]/1000000000;
c[l3]%=1000000000;
l3++;
}
while(l3>1&&c[l3]==0)l3--;
x.l=l3;
for(i=1;i<=l3;i++)
x.a[i]=c[i];
}
void prepare()
{
LL i,j,k;
f[0]=1;
for(LL i=1;i<=9;i++)
f[i]=f[i-1]<<1;
for(i=1;i<f[p];i++)
{
int q=f[p]-i-1;
while(q>0)
{
g[i][2].l++;
g[i][2].a[g[i][2].l]=q%1000000000;
q=q/1000000000;
}
}
for(j=3;j<=l+1;j++)
for(i=1;i<f[p];i++)
for(k=i+1;k<f[p];k++)
add(g[i][j],g[k][j-1]);
}
int main()
{
LL i,j,k;
scanf("%d%d",&p,&w);
r=w%p;
l=w/p;
prepare();
for(i=1;i<=l;i++)
a[i]=f[p];
a[l+1]=f[r];
for(j=2;j<=l+1;j++)
for(i=1;i<a[j];i++)
add(ans,g[i][j]);
printf("%d",ans.a[ans.l]);
for(i=ans.l-1;i>=1;i--)
printf("%09d",ans.a[i]);
cout<<endl;
return 0;
}
/*AC代码*/
#include<iostream>
#include<cstdio>
#include<cstring>
#define LL unsigned long long
#define maxn 30010
using namespace std;
int p,w,r,l,len=1;
int a[maxn],f[15];
struct node
{
int l,a[210];
}g[520][610],ans;
void add(node &x,node &y)
{
int l1=x.l,l2=y.l,l3=1,i,j,k;
LL c[210]={0};
while(l3<=l1||l3<=l2)
{
c[l3]+=(x.a[l3]+y.a[l3]);
c[l3+1]+=c[l3]/1000000000;
c[l3]%=1000000000;
l3++;
}
while(l3>1&&c[l3]==0)l3--;
x.l=l3;
for(i=1;i<=l3;i++)
x.a[i]=c[i];
}
void prepare()
{
LL i,j,k;
f[0]=1;
for(LL i=1;i<=9;i++)
f[i]=f[i-1]<<1;
for(i=1;i<f[p];i++)
{
int q=f[p]-i-1;
while(q>0)
{
g[i][2].l++;
g[i][2].a[g[i][2].l]=q%1000000000;
q=q/1000000000;
}
}
for(j=3;j<=l+1;j++)
for(i=f[p]-1;i>=1;i--)
{
add(g[i][j],g[i+1][j]);
add(g[i][j],g[i+1][j-1]);
}
}
int main()
{
LL i,j,k;
scanf("%d%d",&p,&w);
r=w%p;
l=w/p;
prepare();
for(i=1;i<=l;i++)
a[i]=f[p];
a[l+1]=f[r];
for(j=2;j<=l+1;j++)
for(i=1;i<a[j];i++)
add(ans,g[i][j]);
printf("%d",ans.a[ans.l]);
for(i=ans.l-1;i>=1;i--)
printf("%09d",ans.a[i]);
cout<<endl;
return 0;
}