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

count = 0

for i in range(s+1):

    for j in range(1+s-i):

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

            count += 1

print(count)
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()))
count = 0
for i in range(s + 1):
    for j in range(1 + s - i):
        if 0 <= i <= k and 0 <= j <= k and 0 <= s - i - j <= k:
            count += 1
print(count)

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())) -count = 0 -for i in range(s + 1): -    for j in range(1 + s - i): -        if 0 <= i <= k and 0 <= j <= k and 0 <= s - i - j <= k: -            count += 1 -print(count) +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)