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++: #include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int ans = 0;

int int_sum(int n,int sum){
	vector<vector<int> > v(n+1, vector<int>(sum+1, 0));
	v[0][0] = 1;
	for (int i = 0;i <10;i++) {
		for (int j = n;j >= 1;j--) {
			for (int k = i;k <= sum;k++) {
				v[j][k] += v[j - 1][k - i];
			}
		}
	}
	return v[n][sum];
	
}
int main(){
	int n, sum;
	while (cin >> n >> sum) {
		cout << int_sum(n, sum) << endl;
	}

	}

C++: #include <iostream>

int Judge(int n, int remain, int start)
{
	if (n == 1)
	{
		if (remain < 0)
		{
			return 0;
		}
		if (remain < start)
		{
			return 0;
		}
		if (remain > 9)
		{
			return 0;
		}
		return 1;
	}
	else
	{
		int ret = 0;
		for (int i = start; i < 9; ++i)
		{
			ret += Judge(n - 1, remain - i, i + 1);
		}
		return ret;
	}
}

int main()
{
	int n, s;

	while (std::cin >> n >> s )
	{
		if (n == 0 && s == 0)
		{
			break;
		}
		std::cout << Judge(n, s, 0);
	}

	return 0;
}

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

int BT( int N, int S, int d, int p, int s )
{
	if ( d==N )
		return s==S ? 1 : 0;
	int ans = 0;
	for ( int i=p; i<=S; i++ )
		ans += BT(N,S,d+1,i+1,s+i);
	return ans;
}

int main()
{
	while ( true )
	{
		int n, s;
		cin >> n>>s;
		if ( n ==0 && s==0 )
			break;

		cout << BT(n,s,0,0,0) << endl;

	}

	return 0;
}

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

int counter(int n, int s,int a){
	if(n == 1)
		if(0 <= s && s <= a){
			cout << "OK" << endl;
			return 1;
		} else {
			return 0;
		};
	if(s < 0 || n - 1 > a ) return 0;
	int max = a;
	for(int i = 1; i < n; i++)
		max += (a - i);
	if(s > max) return 0;
	int count = 0;
	for(int j = 1; j <= a; j++){
		if(s - j >= 0)
			count += counter(n - 1, s - j, j - 1);
	}
	return count;
}
int main(){
	int n,s;
	while(cin >> n >> s){
		if(n == 0 && s == 0) break;
		cout << counter(n, s, 9) << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int main(){
	int n,s,a,c;
	vector<int> v;
	for(;;){
		scanf("%d%d",&n,&s);
		if(n==0 && s==0)break;
		v.clear();
		rep(i,10)v.push_back(i<n);
		c=0;
		do{
			a=0;
			rep(i,10)a+=i*v[i];
			c+=(s==a);
		}while(prev_permutation(v.begin(),v.end()));
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,ans;
void func(int num,int goukei,int now){
    if(num==n&&goukei==s){
        //cout<<num<<" "<<goukei<<" "<<now<<endl;
        ans++;
        return;
    }
    if(num>n||goukei>s||now>9)return;
    func(num+1,goukei+now,now+1);
    func(num,goukei,now+1);
}
int main(){
    for(;;){
        ans=0;
        cin>>n>>s;
        if(n==0&&s==0)break;
        func(0,0,0);
        cout<<ans<<endl;
    }
    return 0;
}

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

int n, s;

int dfs(int i, int sum, int rest) {
	if (rest < 0) return 0;
	if (i == 10) return (sum == s && rest == 0) ? 1 : 0;
	return dfs(i + 1, sum, rest) + dfs(i + 1, sum + i, rest - 1);
}

int main() {
	while (true) {
		cin >> n >> s;
		if (n == 0 && s == 0)
			break;
		cout << dfs(0, 0, n) << '\n';
	}
}

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

int n,s,ans = 0;

void dfs(int i,int sum,int num){
    
    if(num == n){
        
        if(sum == s){
            ans++;
        }
        return;
    }
    if(i == 10){
        return;
    }
    //not including i
    dfs(i+1,sum,num);
    //including i
    dfs(i+1,sum + i,num+1);
}

int main(){

    while(cin >> n >> s){
        if(n == 0 && s == 0){
            break;
        }
        dfs(0,0,0);
        cout << ans << endl;
        ans = 0;
    }

    return 0;
}