K, S = list(map(int, input().split()))



num = 0

for x in range(K + 1):

	for y in range(K + 1):

		z = S - x - y

		if z <= K and 0 <= z:

			num += 1

print(num)
K, S = list(map(int, input().split()))



num = 0

for x in range(K + 1):

	rest = S - x

	if 0 <= rest and rest <= K:

		num += rest + 1

	elif K < rest and rest <=2*K:

		num += 2*K + 1 - rest

print(num)
K, S = list(map(int, input().split()))
num = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if z <= K and 0 <= z:
            num += 1
print(num)

K, S = list(map(int, input().split()))
num = 0
for x in range(K + 1):
    rest = S - x
    if 0 <= rest and rest <= K:
        num += rest + 1
    elif K < rest and rest <= 2 * K:
        num += 2 * K + 1 - rest
print(num)

-    for y in range(K + 1): -        z = S - x - y -        if z <= K and 0 <= z: -            num += 1 +    rest = S - x +    if 0 <= rest and rest <= K: +        num += rest + 1 +    elif K < rest and rest <= 2 * K: +        num += 2 * K + 1 - rest