'use strict';
function Main(input) {
  const line = input.split(' ').map(el => +el);

  let count = 0;
  for (let x = 0; x <= line[0]; x++) {
    for (let y = 0; y <= line[0]; y++) {
      for (let z = 0; z <= line[0]; z++) {
        if (x + y + z === line[1]) {
          count++;
        }
      }
    }
  }
  console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));