You are given two integers
K
and
S
. Three variables
X
,
Y
and
Z< /code> take integer values that satisfy the condition \(0<=X,Y,Z<=K\). How many distinct X values are there
, Y
and Z
such that \(X+Y+Z=S\) ?
Input
The input is two integers K
(\(2<=K<=2500\)) and S < /code>(\(0<=S<=3\cdot K\)).
Imprint
Print the number of X
, Y
and Z
triples that satisfy the condition.
Examples
# |
Input |
Output |
Explanations |
1 |
2 2 |
6 |
There are six triplets X, Y and Z that satisfy the condition:
X=0, Y=0, Z=2
X=0, Y=2, Z=0
X=2, Y=0, Z=0
X=0, Y=1, Z=1
X=1, Y=0, Z=1
X=1, Y=1, Z=0 |
2 |
5 15 |
1 |
Only one triple satisfies the condition of the problem:
X=5, Y=5, Z=5 |