#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main() {
	int a=0, b, ans[1024],num[1024];
	for (int i = 0; i < 1024; i++) {
		ans[i] = 0;
		num[i] = 0;
		for (int j = 0; j < 10; j++) {
			int m = 1;
			for (int k = 0; k < j; k++)m *= 2;
			if (i / m % 2 == 1) {
				ans[i] += j;
				num[i]++;
			}
		}
	}
	while (a==a) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) {
			int an = 0;
			for (int i = 0; i < 1024; i++) {
				if (ans[i] == b && num[i] == a) {
					an++;
				}
			}
			printf("%d\n", an);
		}
		else {
			break;
		}
	}
}

