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

cnt=0

for i in range(k+1):

    for j in range(k+1):

        if s>=i+j>=s-k:

            cnt+=1

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

cnt=0

minX=max(s-2*k, 0)

maxX=min(s, k)

for x in range(minX, maxX+1):

    rest=s-x

    if k>=rest:

        cnt+=rest+1

    else:

        cnt+=2*k-rest+1

    

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

k, s = list(map(int, input().split()))
cnt = 0
minX = max(s - 2 * k, 0)
maxX = min(s, k)
for x in range(minX, maxX + 1):
    rest = s - x
    if k >= rest:
        cnt += rest + 1
    else:
        cnt += 2 * k - rest + 1
print(cnt)

-for i in range(k + 1): -    for j in range(k + 1): -        if s >= i + j >= s - k: -            cnt += 1 +minX = max(s - 2 * k, 0) +maxX = min(s, k) +for x in range(minX, maxX + 1): +    rest = s - x +    if k >= rest: +        cnt += rest + 1 +    else: +        cnt += 2 * k - rest + 1