/* THEORY

(1) x1 + x2 + x3 = x, 1 <= x1 <= n, 1 <= x2 <= n, 1 <= x3 <= n, x1 < x2 < x3.

For x1 < x2,
(2) x2 < x - x1 - x2 <= n.

For x1,
(3) x2 > x1, x2 < (x - x1) / 2, x2 >= x - x1 - n.

Therefore,
(4) max(x1 + 1, x - x1 - n) <= x2 < ceil( (x - x1) / 2 ).

*/

function linear_solve(n, x) {
	var res = 0, x1, bottom, top;
	for (x1 = 1; x1 <= n; x1++) {
		bottom = Math.max(x1 + 1, x - x1 - n);
		top = Math.ceil( (x - x1) / 2 );
		res += (top > bottom) ? (top - bottom) : 0;
	}
	return res;
}

/*
const assert = require('assert');
assert(linear_solve(5, 9) === 2);
assert(linear_solve(1, 6) === 0);
assert(linear_solve(2, 6) === 0);
assert(linear_solve(3, 6) === 1);
assert(linear_solve(4, 6) === 1);
assert(linear_solve(4, 7) === 1);
assert(linear_solve(4, 8) === 1);
assert(linear_solve(5, 8) === 2);
*/

line = require('fs').readFileSync('/dev/stdin', 'ascii').split(/\r?\n/);
console.log(line);
for (i in line) {
	if (line[i] === '0 0') break;
	nx = line[i].split(' ');
	console.log(linear_solve(nx[0], nx[1]));
}