#include <iostream>
#include <algorithm>
using namespace std;

int n, s;

int rec(int S, int t, int sum) {
  int res = 0;
  if(t == n) {
    int tmp = s - sum;
    if(tmp >= 0 && tmp%n == 0) {
      int tmp2 = tmp / n;
      if(tmp2 >= 0 && tmp2 <= 9 && !( S>>tmp2 & 1 )) {
	return 1;
      }
    }
    return 0;
  }
  if(sum > s) return 0;
  for(int k = 0; k <= 9; ++k) {
    if(S>>k & 1) continue;
    res += rec(S|1<<k, t+1, sum+t*k);
  }
  return res;
}

void solve() {
  int ans;
  if(n > 10) ans = 0;
  else      ans = rec(0, 1, 0);
  cout << ans << endl;
}

main() {
  while((cin >> n >> s)) solve();
}