#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;

class DFS
{
public:
//	int depth;
	int sum;
	vector <vector <int> > t;
	void init_v (int );
	int dfs (vector <bool> &, int, int, int );
private:

};

void DFS::init_v (int s )
{
//	depth = n;
	sum = s;

	t.resize (11, vector <int> (11, 0 ) );

	int i,j;
	
	for (i = 0; i < 11; ++i){
		for (j = 0; j < 11; ++j){
			t[i][j] = i*j;
		} // end for
	} // end for	
}

int DFS::dfs (vector<bool> & used, int currs, int currd, int n)
{
	if (currs > sum ){
		return 0;
	} // end if

	if (currd == 0 ){
		if (currs == sum ){
			return 1;
		}else{
			return 0;
		} // end if
	} // end if

	int count = 0;
	int i, j;

	for (i = 9, j = n; i >= 0; j = (10 + j - 1 ) % 10, --i ){
		if (!used[j] ){
			used[j] = true;
			count += dfs (used, currs + t[j][currd], currd - 1, n-1 );
			used[j] = false;
		} // end if
	} // end for

	return count;
}
	
int main()
{
	DFS dfs;
//	cut here before submit 
//	freopen("testcase.comb", "r", stdin);

	string str = "";

	while (getline (cin, str ) ){
		int n, s;
		int res = 0;
		stringstream ss(str);
		ss >> n >> s;

		dfs.init_v (s );

		vector <bool> used (10, false );

		res = dfs.dfs (used, 0, n, 9 );

		cout << res << endl;

	} // end loop
		
	return 0;
}