#atcoderABC051B. Sum of Three Integers

Sum of Three Integers

Problem

You are given two integers KK and SS.
Three variable X,YX, Y and ZZ takes integer values satisfying 0X,Y,ZK0≤X,Y,Z≤K.
How many different assignments of values to X,YX, Y and ZZ are there such that X+Y+Z=SX + Y + Z = S?

Constraints

  • 2K25002≤K≤2500
  • 0S3K0≤S≤3K
  • KK and SS are integers.

Input

The input is given from Standard Input in the following format:

KK SS

Output

Print the number of the triples of X,YX, Y and ZZ that satisfy the condition.

Example : 1. in

2 2

Example : 1. out

6

There are six triples of X,YX, Y and ZZ that satisfy the condition:

  • X=0,Y=0,Z=2X = 0, Y = 0, Z = 2
  • X=0,Y=2,Z=0X = 0, Y = 2, Z = 0
  • X=2,Y=0,Z=0X = 2, Y = 0, Z = 0
  • X=0,Y=1,Z=1X = 0, Y = 1, Z = 1
  • X=1,Y=0,Z=1X = 1, Y = 0, Z = 1
  • X=1,Y=1,Z=0X = 1, Y = 1, Z = 0

Example : 2. in

5 15

Example : 2. out

1

The maximum value of X+Y+ZX + Y + Z is 1515, achieved by one triple of X,YX, Y and ZZ.