from sys import stdin

n = input().split(' ')

c = 0

K = int(n[0])

S = int(n[1])

for i in range(int(K)+1):

    for j in range(int(K)+1):

        if(S-(i+j) <= K and S>=i+j):

            c+=1

                

print(c)
k, s = list(map(int, input().split()))

ans = 0

for i in range(k + 1):

	for j in range(k + 1):

		if 0 <= s - i - j <= k:

			ans +=1

print(ans)
from sys import stdin

n = input().split(" ")
c = 0
K = int(n[0])
S = int(n[1])
for i in range(int(K) + 1):
    for j in range(int(K) + 1):
        if S - (i + j) <= K and S >= i + j:
            c += 1
print(c)

k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            ans += 1
print(ans)

-from sys import stdin - -n = input().split(" ") -c = 0 -K = int(n[0]) -S = int(n[1]) -for i in range(int(K) + 1): -    for j in range(int(K) + 1): -        if S - (i + j) <= K and S >= i + j: -            c += 1 -print(c) +k, s = list(map(int, input().split())) +ans = 0 +for i in range(k + 1): +    for j in range(k + 1): +        if 0 <= s - i - j <= k: +            ans += 1 +print(ans)