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

int n,s;
bool p[10];

int rec(int sum,int cnt){
  if(cnt == n) return sum == s;
  int res = 0;
  for(int i=0;i<=9;i++){
    if(p[i]){
      p[i] = false;
      res += rec(i*(cnt+1)+sum,cnt+1);
      p[i] = true;
    }
  }
  return res;
}
      

int main(){
  while(cin >> n >> s){
    memset(p,true,sizeof(p));
    int ans = 0;
    for(int i=0;i<=9;i++){
      p[i] = false;
      ans += rec(i,1);
      p[i] = true;
    }
    cout << ans << endl;
  }
}