process.stdin.resume();
process.stdin.setEncoding('utf8');
     
process.stdin.on('data', function (chunk) {
    var numbers = chunk.toString().split(" ");
	var S = parseInt(numbers.pop()), K = parseInt(numbers.pop());
	
	var c=0;
	for (var X=0; X <= K; X++)
		for (var Y=0; Y <= K; Y++){
			var Z = S - X - Y;
			if (Z >= 0 && Z <= K){
				c++;
			}
		}
	
    process.stdout.write(c.toString());    
     
    process.exit();
});