"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	lines.some(function(line){
		if(line == "0 0") return true;
		var a = line.split(" ").map(Number);
		var n = a[0], x = a[1];
		var count = 0;
		for(var i=1;i<x/3;i++){
			for(var j=i+1;j<x/2;j++){
				var k = x - i - j;
				if(k <= j) break;
				if(k <= n) count++;
			}
		}
		console.log(count);
	});
}