'use strict'

const main = arg => {
    arg = arg.trim().split("\n")
    const K = ~~arg[0].split(" ")[0];
    const S = ~~arg[0].split(" ")[1];
    
    let answer = 0;
    
    for(let i=0; i<=K; i++) {
        for(let j=0; j<=K; j++) {
            let z = S - i - j;
            
            if(0 <= z && z <= K) {
                answer++;
            }
        }
    }
    
    console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))