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

ans = 0

for i in range(K+1):

    if i > K:

        break

    for j in range(K+1):

        if 0 <= S - i - j <= K:

            ans += 1

print(ans)
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)

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

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)

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