#include <cstdio>
#include <iostream>

using namespace std;

int vis[10], ans, cs;

void dfs(int vis[], int i, int cs, int s) {
	if (i > 9) return ;
	if (cs == 3) {
		int sum = 0;
		for (int i=0; i<10; ++i) {
			if (vis[i]) sum += i;
		}
		if (sum == s) ++ans;
		cs = 0;
	}
	else {
		vis[i] = 0;
		dfs(vis, i+1, cs, s);
		vis[i] = 1;
		dfs(vis, i+1, cs+1, s);
		vis[i] = 0;
	}
}

int main() {
	int n, s;
	while (scanf("%d%d", &n, &s), n + s) {
		cs = ans = 0;
		for (int i=0; i<10; ++i) vis[i] = 0;
		dfs(vis, 0, cs, s);
		printf ("%d\n", ans);
	}
	return 0;
}