import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.chomp.split.map!(to!int);
		auto f = new bool[](10);
		int cnt;
		void solve(int sum, int n) {
			if (n == x[0]) {
				if (sum == x[1]) {
					cnt++;
				}
				return;
			}
			foreach (i; 0..10) {
				if (f[i]) continue;
				f[i] = 1;
 				solve(sum + i*(n+1), n+1);
 				f[i] = 0;
			}
		}
		solve(0, 0);
		cnt.writeln;
	}
}