#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<queue>
using namespace std;

int a, b; 
bool used[10];
int sum;
void saiki(int c, int d) {//c?????§??§d
	if (c == a) {
		if (d == b)sum++;
		return;
	}
	for (int e = 0; e < 10; e++) {
		if (!used[e]) {
			used[e] = true;
			saiki(c + 1, d + (c + 1)*e);
			used[e] = false;
		}
	}
}
int main() {
	while (cin >> a >> b) {
		sum = 0;
		saiki(0, 0);
		cout << sum << endl;
	}
}