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.container;

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