K,S=input().split()

K=int(K)

S=int(S)

ans=0

for l in range(K+1):

    for m in range(K+1):

        if l+m<=S and l+m+K>=S:

            ans=ans+1

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



ans=0



for i in range(k+1):

    for j in range(k+1):

        z=s-(i+j)

        if z>=0 and z<=k:

            ans+=1



print(ans)
K, S = input().split()
K = int(K)
S = int(S)
ans = 0
for l in range(K + 1):
    for m in range(K + 1):
        if l + m <= S and l + m + K >= S:
            ans = ans + 1
print(ans)

k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        z = s - (i + j)
        if z >= 0 and z <= k:
            ans += 1
print(ans)

-K, S = input().split() -K = int(K) -S = int(S) +k, s = list(map(int, input().split())) -for l in range(K + 1): -    for m in range(K + 1): -        if l + m <= S and l + m + K >= S: -            ans = ans + 1 +for i in range(k + 1): +    for j in range(k + 1): +        z = s - (i + j) +        if z >= 0 and z <= k: +            ans += 1