"use strict";

var main = function main(input) {
  var K = input.split(' ')[0];
  var S = input.split(' ')[1];
  var count = 0;

  for (var i = 0; i <= K; i++) {
    for (var j = 0; j <= K; j++) {
      var amari = S - i - j;

      if (amari <= K && amari >= 0) {
        count++;
      }
    }
  }

  console.log(count);
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));