"use strict";
const main = arg => {
  let K = arg.split(" ")[0];
  let S = arg.split(" ")[1];
  let cnt = 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){
        	cnt++;
        }
      }
    }
  }
  console.log(cnt);
}

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