#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;

vvi x(11, vi(101));
int reverse(string &s){
    int n = s.size(), n2 = n/2;
    for (int i=0; i<n2; i++)
        swap(s[i], s[n-1-i]);
    return 0;
}

string dec2bin(int n, bool r=false){
	string s="";
	while (n>0){
		if (n%2==1) s+="1";
		else s+="0";
		n/=2;
	}
	if (s=="") s="0";
	if (!r) reverse(s);
	return s;
}

int main(void){
	int m=pow(2,10);
	for (int i=0; i<10; i++)
		for (int j=0; j<101; j++)
			x[i][j] = 0;

	string s;
	for (int i=1; i<m; i++){
		s = dec2bin(i, true);
		s += string(10-s.size(),'0');

		int n=0, c=0;
		for (int i2=0; i2<s.size(); i2++)
			if (s[i2]=='1'){
				n += i2;
				c++;
			}
		x[c][n]++;		
	}

	while (true){
		int a1,a2;
		cin>>a1>>a2;
		if (a1==0 && a2==0) break;
		cout<<x[a1][a2]<<endl;
	}
	return 0;
}