#include<iostream>
#include<cstdlib>
using namespace std;

int bitCount(unsigned int x){
	x = (x>>1 & 0x55555555)+(x & 0x55555555);
	x = (x>>2 & 0x33333333)+(x & 0x33333333);
	x = (x>>4 & 0x0f0f0f0f)+(x & 0x0f0f0f0f);
	x = (x>>8 & 0x00ff00ff)+(x & 0x00ff00ff);
	return (x>>16)+(x & 0x0000ffff);
}

int dp[1024][512];
int main(){
	dp[0][0]=1;
	for(int i=0;i<(1<<10)-1;i++){
		for(int j=0;j<512;j++){
			if(dp[i][j]==0)continue;
			for(int k=0;k<10;k++){
				if(i>>k&1)continue;
				dp[i|1<<k][j+(bitCount(i)+1)*k] += dp[i][j];
			}
		}
	}
	int n,s;
	while(cin>>n>>s){
		if(!n){
			cout<<!s<<endl;
			continue;
		}
		if(512<s){
			cout<<0<<endl;
			continue;
		}
		int ans=0;
		int comb = (1 << n) - 1;
		while (comb < 1 << 10) {
  			int x = comb & -comb, y = comb + x;
  			ans += dp[comb][s];
			comb = ((comb & ~y) / x >> 1) | y;
		}
		cout<<ans<<endl;
	}
	return 0;
}