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



count = 0

for x in range(k+1):

    for y in range(min(s-x+1, k+1)):

        z = s - x - y

        if 0 <= z and z <=k:

            count += 1

print(count)

import sys

input = sys.stdin.readline



def main():

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



    ans = 0

    for x in range(min(S, K), -1, -1):

        for y in range(min(S - x, K), -1, -1):

            if S - x - y <= K:

                # print(x, y, S-x-y)

                ans += 1

            else:

                break

    print(ans)







if __name__ == "__main__":

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

import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

-k, s = list(map(int, input().split())) -count = 0 -for x in range(k + 1): -    for y in range(min(s - x + 1, k + 1)): -        z = s - x - y -        if 0 <= z and z <= k: -            count += 1 -print(count) +import sys + +input = sys.stdin.readline + + +def main(): +    K, S = list(map(int, input().split())) +    ans = 0 +    for x in range(min(S, K), -1, -1): +        for y in range(min(S - x, K), -1, -1): +            if S - x - y <= K: +                # print(x, y, S-x-y) +                ans += 1 +            else: +                break +    print(ans) + + +if __name__ == "__main__": +    main()