"use strict";
    
// 組み合わせ 被り有り
const combineWithRepetitions = (comboOptions, comboLength) => {
  if (comboLength === 1) {
    return comboOptions.map(comboOption => [comboOption]);
  }

  // Init combinations array.
  const combos = [];

  // Eliminate characters one by one and concatenate them to
  // combinations of smaller lengths.
  comboOptions.forEach((currentOption, optionIndex) => {
    const smallerCombos = combineWithRepetitions(
      comboOptions.slice(optionIndex),
      comboLength - 1
    );

    smallerCombos.forEach((smallerCombo) => {
      combos.push([currentOption].concat(smallerCombo));
    });
  });

  return combos;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    const S = parseInt(arg[0].split(" ")[1]);
    
    let array = [];
    
    for(let i=0; i<=K; i++) {
        array.push(i);
    }
    
    const combos = combineWithRepetitions(array, 3);
    const N = combos.length;
    
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        let X = combos[i][0];
        let Y = combos[i][1];
        let Z = combos[i][2];
        
        if(X + Y + Z === S) {
            if(X === Y && Y === Z) {
                answer++;
            } else {
                answer = answer + 3;
            }
        }
    }
    
    // console.log(combos.join("\n"));
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));