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



count = 0

for x in range(k+1):

    for y in range(k +1):

        if ((x + y) <= s) and ((s - (x + y)) <= k):

            count += 1

                

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

count= 0

#全探索は時計が切れる

for x in range(k+1):

    for y in range(k+1):

        if 0 <= s - (x +y) <= k:

            count += 1



print(count)
k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if ((x + y) <= s) and ((s - (x + y)) <= k):
            count += 1
print(count)

k, s = list(map(int, input().split()))
count = 0
# 全探索は時計が切れる
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - (x + y) <= k:
            count += 1
print(count)

+# 全探索は時計が切れる -        if ((x + y) <= s) and ((s - (x + y)) <= k): +        if 0 <= s - (x + y) <= k: