//0070


#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;


int f(const int a[], int size)
{
	int result = 0;
	for(int i = 0; i < size; i++)
	{
		result = result*10 + a[i];
	}
	return result;
}

int main(void)
{
	int n, s, i, t;
	const int N = 10;
	map<int, int> m;
	while(scanf("%d %d", &n, &s) == 2)
	{
		m.clear();
		int a[N] = {0,1,2,3,4,5,6,7,8,9,};
		do
		{
			t = 0;
			for(i = 0; i < n; i++)
			{
				t += (i+1) * a[i];
			}
			if(t == s)
				m[f(a, n)] = t;
		}while( next_permutation(a, a+N) );
		printf("%d\n", m.size());
	}
	return 0;
}