#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n, s;
  while(cin >> n >> s){
     int a[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
     int res = 0;
     do{
       int sum = 0;
       for(int i=0;i<n;i++) sum += (i+1)*a[i];
       if(sum == s) res++;
       reverse(a+n, a+9);
     }while(next_permutation(a, a+9));
     cout << res << endl;
  }
}