#include <iostream>
using namespace std;

int count(int n, int s, int u[]){
	int sum = 0;
	if(n == 1){
		if(s >= 0 && s <= 9 && u[s]) return 1;
		else return 0;
	}
	if(s < 0 || s > 9 * n * (n + 1) / 2) return 0;
	for(int i = 0; i < 10; i++){
		if(u[i]){
			u[i] = 0;
			sum += count(n - 1, s - i * n, u);
			u[i] = 1;
		}
	}
	return sum;
}

int main(){
	int n;
	int u[] = {
		1, 1, 1, 1, 1,
		1, 1, 1, 1, 1
	};
	int s;
	while(cin >> n >> s){
		cout << count(n, s, u) << endl;
	}
	return 0;
}