function main(input) {
	var res = 0;
 	input = input.split(',');
  	const max = input[0];
  	const total = input[1];
	for (var X = 0;X <= max;X++) {
    	for (var Y = 0;Y <= max;Y++) {
        	for(var Z = 0;Z <= max;Z++) {
            	var a = X + Y + Z;
            	if (a == total && Z <= max) res++;
            }
        }
    }
	console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));