# coding = SJIS



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

ans = 0



for x in range(0, k + 1):

    for y in range(0, k + 1):

        z = s - x - y

        if 0 <= z and z <= k:

            ans += 1



print(ans)
# coding = SJIS

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

if s < k:

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

elif s <= 2 * k:

    t = 2 * k - s

    ans = ((k + 1) * (k + 2) / 2) - ((2 * k - s) * ((2 * k - s) + 1) / 2) + (t * (2 * k - ((2 * k - s) - 1)) / 2)

elif s <= 3 * k:

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

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

# coding = SJIS
k, s = list(map(int, input().split()))
if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    ans = (
        ((k + 1) * (k + 2) / 2)
        - ((2 * k - s) * ((2 * k - s) + 1) / 2)
        + (t * (2 * k - ((2 * k - s) - 1)) / 2)
    )
elif s <= 3 * k:
    ans = (3 * k - s + 1) * ((3 * k - s + 1) + 1) / 2
print((int(ans)))

-ans = 0 -for x in range(0, k + 1): -    for y in range(0, k + 1): -        z = s - x - y -        if 0 <= z and z <= k: -            ans += 1 -print(ans) +if s < k: +    ans = (s + 1) * (s + 2) / 2 +elif s <= 2 * k: +    t = 2 * k - s +    ans = ( +        ((k + 1) * (k + 2) / 2) +        - ((2 * k - s) * ((2 * k - s) + 1) / 2) +        + (t * (2 * k - ((2 * k - s) - 1)) / 2) +    ) +elif s <= 3 * k: +    ans = (3 * k - s + 1) * ((3 * k - s + 1) + 1) / 2 +print((int(ans)))