#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

		vector <int> numbers;
		for ( int i = 0; i < s; i++ )
			numbers.push_back( i );

		int kotae = 0;
		do
		{
			bool continue_flag = false;
			for ( int i = 0; i < n-1; i++ )
			{
				if ( numbers[i] > numbers[i+1] )
				{
					continue_flag = true;
					break;
				}
			}
			if ( continue_flag )
				continue;
			int sum = 0;
			for ( int i = 0; i < n; i++ )
			{
				sum += numbers[i];
			}
			if ( sum == s )
			{
				kotae++;
			}
		} while ( next_permutation( numbers.begin(), numbers.end() ) );

		cout << kotae / 6 << endl;

	}
	return 0;
}