function Main(input){
  input = input.split(' ');
  var K = input[0];
  var S = input[1];
  var count=0;
  for(var i=0;i<=K;i++){
    for(var j=0;j<=K;j++){
      for(var k=0;k<=K;k++){
        if(i+j+k==S){
          count++;
        }
      }
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));