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

ans = 0

for x in range(k + 1):

    for y in range(k + 1):

        z = s - x - y

        if z >= 0 and z <= k:

            ans += 1

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

ans = 0

for X in range(K + 1):

    for Y in range(K + 1):

        if 0 <= S - X - Y <= K:

            ans += 1

print(ans)
k, s = list(map(int, input().split()))
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if z >= 0 and z <= k:
            ans += 1
print(ans)

K, S = list(map(int, input().split()))
ans = 0
for X in range(K + 1):
    for Y in range(K + 1):
        if 0 <= S - X - Y <= K:
            ans += 1
print(ans)

-k, s = list(map(int, input().split())) +K, S = list(map(int, input().split())) -for x in range(k + 1): -    for y in range(k + 1): -        z = s - x - y -        if z >= 0 and z <= k: +for X in range(K + 1): +    for Y in range(K + 1): +        if 0 <= S - X - Y <= K: