#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int dfs (vector<bool> & used, int n, int curr_sum, int sum, int curr_depth, int depth )
{
	if (curr_depth > depth ){
		if (curr_sum == sum ){
			return 1;
		}else{
			return 0;
		} // end if
	} // end if
	int count = 0;
	int i, j;

	for (i = 0, j = n; i < 10; j = (j + 1) % 10, ++i){
		if (!used[j]){
			used[j] = true;
			curr_sum += j*curr_depth;
			count += dfs (used, n+1, curr_sum, sum, curr_depth + 1, depth );
			curr_sum -= j*curr_depth;
			used[j] = false;
		} // end if
	} // end for

	return count;
}
	
int main()
{
//	cut here before submit 
//	freopen("testcase.comb", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		int n, sum;
		stringstream ss(str);
		ss >> n >> sum;
		vector <bool> used (10, false );
		
//		cout << "n: " << n << " sum: " << sum << endl;

		int res = dfs (used, 0, 0, sum, 1, n );
		cout << res << endl;

	} // end loop

//	cout << res << endl;	
		
	return 0;
}