#include <bits/stdc++.h>
using namespace std;

int n,s;

int solve(int d,int sum,int num){
	int ret = 0;
	if((s - sum) / (n - d) > (s / n))return 0;
	if(d == n){
		if(sum == s){
			return 1;
		}else{
			return 0;
		}
	}
	for(int j = num + 1;j <= 1000;j++){
		ret += solve(d+1,sum+j,j);
	}
	return ret;
}

int main(){
	while(cin >> n >> s,n){
		cout << solve(0,0,0)<<endl;
	}
	return 0;
}