"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    const S = parseInt(arg[0].split(" ")[1]);
    
    let answer = 0;
    
    for(let i=0; i<=K; i++) {
        for(let j=0; j<=K; j++) {
            let X = i;
            let Y = j;
            
            if(i + j > S) continue;
            
            if(S - (i+j) <= K) {
                // console.log("X:" + X);
                // console.log("Y:" + Y);
                
                answer++;
            }
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));