Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func solve(a, b, c int) int {
	if a == 1 && b >= c && b < 10 {
		return 1
	}
	if a == 1 {
		return 0
	}
	ret := 0
	for i := c; i < 10 && i < b; i++ {
		ret += solve(a-1, b-i, i+1)
	}
	return ret
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		fmt.Println(solve(a, b, 0))
	}
}

C++: from collections import deque


class Bt(object):
    def __init__(self):
        self.used = [False] * 10  # 0-9????????°???????????¨?????????????????????????????°
        self.answers = []  # ?????¶???????????????????????????
        self.Q = deque()  # ????????§???????????¢??????????????°???????¨???¶??¨

    def solve(self, num, remain):
        # ????´¢??????????°??????§?????????????????????????????§????????????????????§????????°??????????????????????????????
        try:
            min_choice = max(self.Q) + 1
        except ValueError:
            min_choice = 0

        if min_choice <= remain < 10 and self.used[remain] == False and num == 1:
            self.Q.append(remain)
            # print('{0}'.format(self.Q))
            ans = [*self.Q]
            ans.sort()
            if not ans in self.answers:
                self.answers.append(ans)
            self.Q.pop()
            # self.answers.append(1)
            return
        elif num < 0:
            return

        for i in range(min_choice, 10):
            if self.used[i] == False and (remain - i) >= 0:
                self.used[i] = True
                self.Q.append(i)
                self.solve(num - 1, remain - i)
                self.used[i] = False
                self.Q.pop()


if __name__ == '__main__':
    while True:
        # ??????????????\???
        n, s = [int(x) for x in input().split(' ')]
        if n == 0 and s == 0:
            break

        if 0 <= s <= 45:
            # ????????????
            a = Bt()
            a.solve(n, s)

            # ???????????¨???
            print(len(a.answers))
        else:
            print(0)

C++: #include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> P;
int main()
{
	int n, s;
	while (cin >> n >> s, n||s)
	{
		set<P> ans;
		P v;
		for (int i=0; i<10; i++)
			v.push_back(i);

		do
		{
			P t(v.begin(), v.begin()+n);
			int sum  = 0;
			for (int i=0; i<n; i++)
				sum += t[i];
			if (sum == s)
			{
				sort(t.begin(), t.end());
				ans.insert(t);
			}
		} while(next_permutation(v.begin(), v.end()));

		cout << ans.size() << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef vector<int> comb;

inline int first(int n){
	return ((1 << n) - 1);
}

int nextSet(int x){
	int small, ripple, newSmall,ones;
	
	small = x & -x;
	ripple = x + small;
	newSmall = ripple & -ripple;
	ones = (( newSmall / small ) >> 1) - 1;
	
	return (ripple | ones);
}

comb setComb(int s, int n){
	comb c;
	for(int i=1 ; i<=n ; i++){
		if( s & 1 ) c.push_back(i-1);
		s >>= 1;
	}
	return c;
}

int main(){
	int n=10, k, x, s, sum, ans;
	comb c;
	
	while( cin >> k >> s , k || s ){
		ans = 0;
		x = first(k);
		while( !(x & ~first(n) ) ){
			c = setComb( x , n );
			sum = 0;
			for(int i=0 ; i<c.size() ; i++){
				sum += c.at(i);
			}
			if( sum == s ) ans++;
			x = nextSet( x );
		}
		cout << ans << endl;
	}
}

C++: //??±???????????¢?´¢

#include<iostream>
using namespace std;
int n, s;
int cou;//????????????????????????

//sum???????¨?
//num_of_add????¶?????????°????????°
void dfs(int i, int sum,int num_of_add) {
	if (sum == s&&num_of_add==n) {
		cou++;
		return;
	}
	if (n == num_of_add||i==10)return;

	dfs(i + 1, sum, num_of_add);
	dfs(i + 1, sum + i, num_of_add + 1);
}

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int n, ans;

//選択しきっていないのに答え以上か、繰り返し初期値が９を超えているなら
bool isIllegal(int pos, int sum, int before) {
    return(sum > ans || before > 9);
}
//深さ優先探索
int dfs(int pos, int sum, int before) {
    int ret = 0;
    if(pos == n) {
        if(sum == ans) return(1);
        else           return(0);
    }
    if(isIllegal(pos, sum, before)) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(pos + 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    while(cin >> n >> ans, n + ans != 0) {
        cout << dfs(0, 0, 0) << endl;
    }
    return(0);
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
void check(int z);
bool flg[10]={0};
int W_book[10]={0};
int bookcheck[1000][10]{{0}};
int sum=0;
int n,s;
int ans=0;
int main(void){
	for(;;){
        cin>>n>>s;
        if(n==0)break;
        for(int i=0;i<10;i++)W_book[i]=-1,flg[i]=0;
        ans=0,sum=0;
        check(0);
        cout<<ans<<endl;
	}

	return 0;
}
void check(int z){
    if(n==z){
        if(sum==s){
            for(int i=0;i<n;i++){
                bookcheck[ans][i]=W_book[i];

               sort(bookcheck[ans],bookcheck[ans]+n);
               reverse(bookcheck[ans],bookcheck[ans]+n);

            }
            bool notcnt=0;
            for(int i=0;i<ans;i++){
                bool W_flg=0;
                for(int j=0;j<n;j++){
                    if(bookcheck[ans][j]!=bookcheck[i][j]){
                        W_flg=1;
                        break;
                    }
                }
                if(W_flg==0)notcnt=1;
            }
            if(notcnt==0){
                int q=0;
                for(int i=0;i<n;i++){
                    q+=bookcheck[ans][i];
                   //cout<<bookcheck[ans][i];
                }
                //cout<<endl;
                if(q==s)ans++;
            }
        }
        return;
    }
    else {
        for(int i=0;i<10;i++){
            if(flg[i]==0&&sum+i<=s){
               // cout<<i<<"."<<z<<endl;
                sum+=i,flg[i]=1;
                W_book[z]=i,check(z+1),W_book[z]=-1;
                sum-=i,flg[i]=0;
            }
            /*else if(z==n-1&&flg[i]==0&&sum+i==s){
               // cout<<i<<"."<<z<<endl;
                sum+=i,flg[i]=1;
                W_book[z]=i,check(z+1),W_book[z]=-1;
                sum-=i,flg[i]=0;
            }*/
        }
    }

}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n,sum;cin>>n>>sum,n|sum;){
		vi num(10);
		rep(i,10)
			num[i]=i;
		
		int counter=0;
		do{
			if(accumulate(num.begin(),num.begin()+n,0)==sum)
				counter++;
			reverse(n+allof(num));
		}while(next_permutation(allof(num)));
		
		int fact=1;
		rep(i,n)
			fact*=i+1;
		
		cout<<counter/fact<<endl;
	}
	
	return 0;
}