#include<iostream>
#define MAX 10
#define S_MAX 330

using namespace std;

int ans;
int s;
int gp[MAX];
int gnums[MAX];
int qq[MAX+1][MAX+1];

/* genperm1 from http://www5.airnet.ne.jp/tomy/cpro/pe1.htm (C) Tomy */
void genperm1(int p[], int n)
{
	int c[MAX], *pc, *q;
	int k, t;

	for(k = 1, q = p, pc = c; k <= n; )	*q++ = *pc++ = k++;
	k = 1;
	pc = c;
	do
	{
		int tmp = 0;

		t = *(p + k);
		*(p + k) = *(q = p + ((k & 1)? *pc: 0));
		*q = t;
		for(int i = 0; i < n; i++){
			tmp += qq[i + 1][gnums[p[i] - 1]];
			if( tmp > s ) break;
		}
		if( tmp == s ) ans++;
		k = 1;
		pc = c;
		while(*pc == 0)	*pc++ = k++;
		(*pc)--;
	} while(k < n);
}

void comb(int n, int k){
	bool loop = false;

	for(int i = 0; i < k; i++) gnums[i] = i;

	do{
		loop = false;

		// TODO
		genperm1(gp, k);
		
		for(int pk = k - 1; pk >= 0; pk--){
			gnums[pk]++;
			if( gnums[pk] <= n - (k - pk) ){
				for(int j = pk + 1; j < k; j++){
					gnums[j] = gnums[j - 1] + 1;
				}
				pk++;
				loop = true;
				break;
			}
		}
	}while(loop);
}

int main(int c, char *argv[]){
	for(int i = 0; i < sizeof(qq)/sizeof(qq[0]); i++){
		for(int j = 0; j < sizeof(qq[0])/sizeof(qq[0][0]); j++){
			qq[i][j] = i * j;
		}
	}
	while( 1 ){
		int n;

		cin >> n >> s;
		if( cin.eof() ) break;

		ans = 0;
		if( s >= 0 && s <= S_MAX ) comb(10, n);

		cout << ans << endl;
	}
	return 0;
}