#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>

using namespace std;

int comb[10];
int n,s;
int a[10];
int cnt=0;

void dfs(int num,int idx){
  if(num==n){
    int aa[10];
    for(int i = 0; i < num; i++)
      aa[i]=a[i];
    do{
      int leftS=s;
      for(int i = n-1; i >= 0; i--){
  	leftS-=(i+1)*aa[i];
  	if(leftS<0)break;
      }
      if(leftS==0)
  	cnt++;
    }while(next_permutation(aa,aa+num));
  }
  else{
    for(int i = idx; i < 10; i++){
      a[num]=i;
      dfs(num+1,i+1);
    }
  }
}


int main(){
  while(cin>>n>>s&&!(n==0&&s==0)){
    cnt=0;
    dfs(0,0);
    cout<<cnt<<endl;
  }


  return 0;
}