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



ans = 0

for x in range(K+1):

    for y in range(K+1):

        z = S-(x+y)

        if 0 <= z and z <= K:

            ans += 1

print(ans)



# python3 (3.4.3)

import sys

input = sys.stdin.readline



# main

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



ans = 0

for x in range(K+1):

    for y in range(K+1):

        if 0 <= S-(x+y) <= K:

            ans += 1



print(ans)
K, S = list(map(int, input().split()))
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - (x + y)
        if 0 <= z and z <= K:
            ans += 1
print(ans)

# python3 (3.4.3)
import sys

input = sys.stdin.readline
# main
K, S = list(map(int, input().split()))
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= S - (x + y) <= K:
            ans += 1
print(ans)

+# python3 (3.4.3) +import sys + +input = sys.stdin.readline +# main -        z = S - (x + y) -        if 0 <= z and z <= K: +        if 0 <= S - (x + y) <= K: