function main(input) {
  const args = input.split(' ');
  const N = parseInt(args[0], 10);
  const K = parseInt(args[1], 10);
  let count = 0;
  
  for (let x = 0; x <= N; x++) {
    for (let y = 0; y <= N; y++) {
      for (let z = 0; z <= N; z++) {
        if (K === x + y + z) { count++; }
      }
    }
  }
  console.log(count);
}

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