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

way = 0

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

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

        z = S - x -y

        if(z>=0 and z<=K):

            way += 1

print(way)
# -*- coding: utf-8 -*-



def solve(K, S):

    count = 0

    

    for i in range(K+1):

        for j in range(K+1):

            if(0<= S-i-j <= K):

                count += 1

                

    print(count)



if __name__ == '__main__': 

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

    

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

# -*- coding: utf-8 -*-
def solve(K, S):
    count = 0
    for i in range(K + 1):
        for j in range(K + 1):
            if 0 <= S - i - j <= K:
                count += 1
    print(count)


if __name__ == "__main__":
    K, S = list(map(int, input().split()))
    solve(K, S)

-K, S = list(map(int, input().split())) -way = 0 -for x in range(0, K + 1): -    for y in range(0, K + 1): -        z = S - x - y -        if z >= 0 and z <= K: -            way += 1 -print(way) +# -*- coding: utf-8 -*- +def solve(K, S): +    count = 0 +    for i in range(K + 1): +        for j in range(K + 1): +            if 0 <= S - i - j <= K: +                count += 1 +    print(count) + + +if __name__ == "__main__": +    K, S = list(map(int, input().split())) +    solve(K, S)