#input

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



#count

counter = 0

for x in range(0,K+1):

    for y in range(0,K+1):

        z = S - x - y

        if 0 <= z <= K:

            counter = counter + 1



#print

print(counter)
INT = lambda: int(eval(input()))

INTM = lambda: list(map(int,input().split()))

STRM = lambda: list(map(str,input().split()))

STR = lambda: str(eval(input()))

LIST = lambda: list(map(int,input().split()))

LISTS = lambda: list(map(str,input().split()))

def do():

    k,s=INTM()

    ct=0

    for x in range(k+1):

        for y in range(k+1):

            z=s-x-y

            if 0<=z and z<=k:

                ct+=1

    print(ct)

if __name__ == '__main__':

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

INT = lambda: int(eval(input()))
INTM = lambda: list(map(int, input().split()))
STRM = lambda: list(map(str, input().split()))
STR = lambda: str(eval(input()))
LIST = lambda: list(map(int, input().split()))
LISTS = lambda: list(map(str, input().split()))


def do():
    k, s = INTM()
    ct = 0
    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if 0 <= z and z <= k:
                ct += 1
    print(ct)


if __name__ == "__main__":
    do()

-# input -K, S = list(map(int, input().split())) -# count -counter = 0 -for x in range(0, K + 1): -    for y in range(0, K + 1): -        z = S - x - y -        if 0 <= z <= K: -            counter = counter + 1 -# print -print(counter) +INT = lambda: int(eval(input())) +INTM = lambda: list(map(int, input().split())) +STRM = lambda: list(map(str, input().split())) +STR = lambda: str(eval(input())) +LIST = lambda: list(map(int, input().split())) +LISTS = lambda: list(map(str, input().split())) + + +def do(): +    k, s = INTM() +    ct = 0 +    for x in range(k + 1): +        for y in range(k + 1): +            z = s - x - y +            if 0 <= z and z <= k: +                ct += 1 +    print(ct) + + +if __name__ == "__main__": +    do()