#include <iostream>

using namespace std;

void initPerm(int* b, int n)
{
	for (int i=0; i<10-n; i++) b[i] = 0;
	for (int i=10-n; i<10; i++) b[i] = i + n - 9;
}

bool nextPerm(int* b, int n)
{
	int pos;
	int occurrence[10] = {0};
	for (pos=9; pos>0; pos--) {
		occurrence[b[pos]]++;
		if (b[pos-1] < b[pos]) {
			occurrence[b[pos-1]]++;
			break;
		}
	}
	if (pos == 0) return false;
	
	for (int i = b[pos-1] + 1; i<=n; i++) {
		if (occurrence[i] > 0) {
			b[pos-1] = i; occurrence[i]--; break;
		}
	}
	for (int i=0; pos<10; pos++) {
		while (occurrence[i]==0) i++;
		b[pos] = i;
		occurrence[i]--;
	}
	return true;
}

int main()
{
	int n, s;
	
	while (cin >> n >> s) {		
		int order[10] = {0};
		initPerm(order, n);
		
		int count = 0;
		
		do {
			int sum = 0;
			for (int i=0; i<10; i++) sum += (order[i]>0) ? i * order[i] : 0;
			if (sum == s) { 
				//for (int i=0; i<10; i++) {
				//	if (isMember[i]) cout << i << " ";
				//}
				//cout << endl;
				count++;
			}
		} while ( nextPerm(order, n) );
		
		cout << count << endl;
	}
	
	return 0;
}