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

  let patterns = [];
  for (let x = 0; x <= line[0]; x++) {
    if (x > line[1]) continue;
    for (let y = x; y <= line[0]; y++) {
      if (y > line[1]) continue;
      for (let z = y; z <= line[0]; z++) {
        if (x + y + z === line[1]) {
          patterns.push([x, y, z]);
        }
      }
    }
  }

  let result = 0;
  for (let i = 0; i < patterns.length; i++) {
    const pattern = patterns[i];
    if (pattern[0] == pattern[1]) {
      if (pattern[0] == pattern[2]) {
        result += 1;
      } else {
        result += 3;
      }
      continue;
    }
    if (pattern[0] == pattern[2] || pattern[1] == pattern[2]) {
      result += 3;
      continue;
    }
    result += 6;
  }
  console.log(result);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));