#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

void printv(vi v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
		}cout << endl;
		return ;
		}

int main() {
	while(1){
	
	int n,s; cin >> n >> s;
	if (n + s == 0) break;
	int ans = 0;
	vi loop(10,1);
	for (int i = 0; i < 10; i++){
		if (10 - i > n){
			loop[9-i] = 0;
		}
		
	}

	
	
	vi aold_used(10,0);
	vi bold_used(10,0);
	vi cold_used(10,0);
	vi dold_used(10,0);
	vi eold_used(10,0);
	vi fold_used(10,0);
	vi gold_used(10,0);
	vi hold_used(10,0);
	vi iold_used(10,0);
	vi jold_used(10,0);
	for (int a = 0; a <= 9*loop[0]; a++){
		vi used(10,0);
		aold_used = used;
		used[a] = 1;
		for (int b = a*loop[1]; b <= 9*loop[1]; b++){
			bold_used = used;
			if (used[b] == 1 and loop[1] != 0) continue;
			else if(loop[1] != 0) used[b] = 1;
			for (int c = b*loop[2]; c <= 9*loop[2]; c++){
				cold_used = used;
				if (used[c] == 1 and loop[2] != 0) continue;
				else if(loop[2] != 0) used[c] = 1;
				for (int d = c*loop[3]; d <= 9*loop[3]; d++){
					dold_used = used;
					if (used[d] == 1 and loop[3] != 0) continue;
					else if(loop[3] != 0) used[s] = 1;
					for (int e = d*loop[4]; e <= 9*loop[4]; e++){
						eold_used = used;
						if (used[e] == 1 and loop[4] != 0) continue;
						else if(loop[4] != 0) used[e] = 1;
						for (int f = e*loop[5]; f <= 9*loop[5]; f++){
							fold_used = used;
							if (used[f] == 1 and loop[5] != 0) continue;
							else if(loop[5] != 0) used[f] = 1;
							for (int g = f*loop[6]; g <= 9*loop[6]; g++){
								gold_used = used;
								if (used[g] == 1 and loop[6] != 0) continue;
								else if(loop[6] != 0) used[g] = 1;
								for (int h = g*loop[7]; h <= 9*loop[7]; h++){
									hold_used = used;
									if (used[h] == 1 and loop[7] != 0) continue;
									else if(loop[7] != 0) used[h] = 1;
									for (int i = h*loop[8]; i <= 9*loop[8]; i++){
										iold_used = used;
										if (used[i] == 1 and loop[8] != 0) continue;
										else if(loop[8] != 0) used[i] = 1;
										for (int j = i*loop[9]; j <= 9*loop[9]; j++){
											jold_used = used;
											if (used[j] == 1 and loop[9] != 0) continue;
											else if(loop[9] != 0) used[j] = 1;
											if (a + b + c + d + e + f + g + h + i + j == s){
												ans++;
											}
											used = jold_used;
										}	
										used = iold_used;
									}
									used = hold_used;
								}
								used = gold_used;
							}
							used = fold_used;
						}
						used = eold_used;
					}
					used = dold_used;
				}
				used = cold_used;
			}
			used = bold_used;
		}
		used = aold_used;
	}

	cout << ans << endl;
	}
}