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

ans = 0



for i in range(K + 1):

    if i > S:

        break

    for j in range(K + 1):

        s = i + j

        if s > S:

            break

        Z = S - s

        if 0 <= Z <= K:

            ans += 1



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

ans = 0



for i in range(min(S + 1, K + 1)):

    s = S - i

    if s > 2 * K:

        continue

    ans += min(K, s) - max(0, s - K) + 1

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

K, S = list(map(int, input().split()))
ans = 0
for i in range(min(S + 1, K + 1)):
    s = S - i
    if s > 2 * K:
        continue
    ans += min(K, s) - max(0, s - K) + 1
print(ans)

-for i in range(K + 1): -    if i > S: -        break -    for j in range(K + 1): -        s = i + j -        if s > S: -            break -        Z = S - s -        if 0 <= Z <= K: -            ans += 1 +for i in range(min(S + 1, K + 1)): +    s = S - i +    if s > 2 * K: +        continue +    ans += min(K, s) - max(0, s - K) + 1