function Main(input) {
input = input.split(" ");
var k = Number(input[0]);
var s = Number(input[1]);
var x = 0;
var y = 0;
var z = 0;
var count = 0;
for(x = 0; x <= k; x++){
for(y = 0; y <= k; y++){
for(z = 0; z <= k; z++){
 if((x+y+z) === s) count++;
}
}
}
console.log(count);
}

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