console.log((args=>{
  const [[K,S]] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  let count = 0;
  for ( let x = Math.min(K,S); x >= 0; x-- ) {
    for ( let y = Math.min(K,S-x); y >= Math.max(0,S-x-K); y-- ) count++;
  }
  return count.toString();
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
