var n, x;

function main(){
	while(n = scan()){
		x = scan();
		var ans = 0;
		rep(1, n + 1, function(i){
			rep(i + 1, n + 1, function(j){
				var k = x - i - j;
				if(j < k && k <= n){
					++ans;
				}
			});	
		});
		print(ans);
	}
}

function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});