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 0<=z<=K:

            ans += 1

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

a = ((s+1)*(s+2))//2

b = ((s-k)*(s-k+1))//2

c = (((abs(s-k*3))+1)*((abs(s-k*3))+2))//2



if s <= k:

    print(a)

elif s <= k*2:

    print((a-b*3))

elif s <= k*3:

    print(c)
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 0 <= z <= K:
            ans += 1
print(ans)

k, s = list(map(int, input().split()))
a = ((s + 1) * (s + 2)) // 2
b = ((s - k) * (s - k + 1)) // 2
c = (((abs(s - k * 3)) + 1) * ((abs(s - k * 3)) + 2)) // 2
if s <= k:
    print(a)
elif s <= k * 2:
    print((a - b * 3))
elif s <= k * 3:
    print(c)

-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 0 <= z <= K: -            ans += 1 -print(ans) +k, s = list(map(int, input().split())) +a = ((s + 1) * (s + 2)) // 2 +b = ((s - k) * (s - k + 1)) // 2 +c = (((abs(s - k * 3)) + 1) * ((abs(s - k * 3)) + 2)) // 2 +if s <= k: +    print(a) +elif s <= k * 2: +    print((a - b * 3)) +elif s <= k * 3: +    print(c)