//r[n]:当前第几列的值。
//l[n]:当前第几行的值。
暴力+减止
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int n=1e3;
int a,b,c,l[n],r[n],an;
void dfs(int x,int y)
{if(x==b+1){an++;return ;}for(int i=0;i<=a;i++){l[x]+=i;r[y]+=i;if(l[x]<=a&&r[y]<=a){int v=0;if(x==b){if(r[y]==a){v++;}}else{v++;}if(y==b){if(l[x]==a){v++;}}elsev++;if(v==2){dfs(x+(y/b),y%b+1);}}l[x]-=i;r[y]-=i;}
}
signed main()
{ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);cin>>a>>b;dfs(1,1);cout<<an<<endl;
}