#include <iostream>
#include <algorithm>
using namespace std;
bool p[10];
int m = 9;
int search(int n, int s, int t){
  int d = t - s;
  if(n == 1){
    if(!p[d]) return 1;
    else return 0;
  }
  int r = 0;
  for(int j = min(d/n,9); j >= 0; j--){
    if (m == j) m--;
    if (d - n * j > m * (n-1)) break;
    if(!p[j]) {
      p[j] = true;
      r += search(n-1, s + n*j, t);
      p[j] = false;
    }
    if (m < j) m = j;
  }
  return r;
}
int main()
{
  int n,s;
  while(cin >> n >> s){
    cout << search(n,0,s) << endl;
  }
  return 0;
}