#include <iostream>
#include <algorithm>

using namespace std;

int memo[1001][11][11];

int func(int n, int s, int k, int t, int c, bool used[10])
{
  if(memo[t][k][c] >= 0){
    return memo[t][k][c];
  }
  if(n == k && t == s){
    return 1;
  } else if(n-1 == k && t == s && used[0]){
    return 1;
  } else if(n-1 == k){
    int v = s-t;
    if(v < 0){
      return 0;
    } else if(v%n == 0 && used[v/n]){
      return 1;
    }
  }
  if(n == k || t >= s){
    return 0;
  }
  int u = 0;
  for(int i = 0; i < 10; i++){
    if(used[i]){
      used[i] = false;
      u += func(n, s, k+1, t+(k+1)*i, i, used);
      used[i] = true;
    }
  }
  memo[t][k][c] = u;

  return u;
}

int main()
{
  int n, s;
  bool used[10];

  while(cin>>n>>s){
    fill(used, used+10, true);
    fill(&memo[0][0][0], &memo[1000][10][10], -1);
    cout << func(n, s, 0, 0, 0, used) << endl;
  }

  return 0;
}