#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;
const int MOD = 1e9 + 7;
 

int main(){
	int n, s, ans;
	while(cin>>n>>s){
		if(n == 0 && s == 0) break;
		vector<int> v(10, 0);
		rep(i, n) v[i] = i;
		set<vector<int> > st;
		ans = 0;
		do{
			vi u(v.begin(), v.begin() + n);
			if(st.count(u)) continue;
			st.insert(u);
			int sum = 0;
			for(int i =0; i < n; i++){
				sum += v[i] * (i + 1);
			}
			if(sum == s) ans++;
		}while(next_permutation(all(v)));
		cout<<ans<<endl;
	}
}