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

ans = 0



if 3*K < S:

    print(ans)

    exit()



for X in range(K+1):

    for Y in range(K+1):

        Z = S - X - Y

        if Z < K + 1 and Z > -1:

            ans += 1

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

ans = 0



for T in range(S-K, S+1):

    if T <= K:

        ans += max(0, T+1)

    else:

        ans += max(0, 2*K - T +1)

print(ans)
K, S = list(map(int, input().split()))
ans = 0
if 3 * K < S:
    print(ans)
    exit()
for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if Z < K + 1 and Z > -1:
            ans += 1
print(ans)

K, S = list(map(int, input().split()))
ans = 0
for T in range(S - K, S + 1):
    if T <= K:
        ans += max(0, T + 1)
    else:
        ans += max(0, 2 * K - T + 1)
print(ans)

-if 3 * K < S: -    print(ans) -    exit() -for X in range(K + 1): -    for Y in range(K + 1): -        Z = S - X - Y -        if Z < K + 1 and Z > -1: -            ans += 1 +for T in range(S - K, S + 1): +    if T <= K: +        ans += max(0, T + 1) +    else: +        ans += max(0, 2 * K - T + 1)