function main(input) {
  const trimInput = input.trim();
  const inputs = trimInput.split(' ');
  const K = inputs[0];
  let S = inputs[1];
  S = Number(S);
  let count = 0;
  for(let X = 0; X <= K; X++) {
    for(let Y = 0; Y <= K; Y++) {
      for(let Z = 0; Z <= K; Z++) {
        if (X + Y + Z === S) {
          count++;
        }
      }
    }
  }
  console.log(count);
}

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