#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int getSum( string number )
{
	int res = 0;

	for ( unsigned int i = 0; i < number.length(); i++ )
	{
		res += ( number[i] - '0' ) * ( i + 1 );
	}

	return res;
}

int main()
{
	int n, s;

	while ( cin >> n >> s )
	{
		string number = "0123456789";
		set<string> dis;
		
		sort( number.begin(), number.end() );

		do
		{
			string seq = number.substr( 0, n );
			if ( getSum( seq ) == s )
			{
				dis.insert( seq );
			}
		} while ( next_permutation( number.begin(), number.end() ) );
	
		cout << dis.size() << endl;
	}


	return 0;
}