function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var max = parseInt(line[0]);
    var sum = parseInt(line[1]);
    var count = 0;
    for(var x = 0; x<=max; x++){
        for(var y = 0; y<=max; y++){
            var z = sum - (x+y);
            if(z>=0 && z<=max){
                count++;
            }
        }
    }
    
    console.log(count);

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