#include<iostream>
#include <cstdio>
#include <cstring>


using namespace std;



int n, s;
int kazu = 0;
int c = 0;
int i = 0;
int j = 0;
int q = 0;
int sum = 0;
int date[15] = { 0 };




int sub(int start, int n, int x){
	if (x == n){
		x = 1;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){

				if (date[i] == date[j] && x < n + 1 && i != j){
					kazu++;
				}
			}
		}
		if (kazu == 0){
			for (int i = 0; i < n; i++) {
				sum += date[i] * x;
				x++;

				
			}


		}
		kazu = 0;
		if (sum == s){
			q++;
		}
		sum = 0;
		return 0;
	}

	for (int i = 0; i < 10; i++){

		date[x] = i;

		sub(i, n, x + 1);
	}


}





int main(){

	n = 0;
	while (~scanf("%d %d", &n, &s)){
		if (n == 0 && s == 0)break;
		sub(0, n, 0);


		cout << q << endl;
		q = 0;
	}
}