#include<iostream>
using namespace std;

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

		for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			if(j >= i) break;
		for(int k = 0; k < 10; k++){
			if(k >= j) break;
			if(i + j + k == s) ans++;
		}
		}
		}

		cout << ans << endl;
	}
}