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



Xs = [i for i in range(K+1)]

Ys = Xs[:]



count = 0

for x in Xs:

    for y in Ys:

        if 0<= S - x - y <= K:

            count += 1

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



Xs = [i for i in range(K+1)]



count = 0

for x in Xs:

    yz = S - x

    if 0 <= yz  <= K*2:

        count += K+1-abs(K-yz)

    

print(count)
K, S = list(map(int, input().split()))
Xs = [i for i in range(K + 1)]
Ys = Xs[:]
count = 0
for x in Xs:
    for y in Ys:
        if 0 <= S - x - y <= K:
            count += 1
print(count)

K, S = list(map(int, input().split()))
Xs = [i for i in range(K + 1)]
count = 0
for x in Xs:
    yz = S - x
    if 0 <= yz <= K * 2:
        count += K + 1 - abs(K - yz)
print(count)

-Ys = Xs[:] -    for y in Ys: -        if 0 <= S - x - y <= K: -            count += 1 +    yz = S - x +    if 0 <= yz <= K * 2: +        count += K + 1 - abs(K - yz)