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 k >= z >= 0:

            ans += 1

print(ans)
import sys

input = sys.stdin.readline

def main():

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

    CNT = 0

    for x in range(K+1):

        for y in range(K+1):

            if S - x -y >= 0 and S - x -y <= K:

                CNT += 1

    print(CNT)            



if __name__ == '__main__':

    main()
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 k >= z >= 0:
            ans += 1
print(ans)

import sys

input = sys.stdin.readline


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


if __name__ == "__main__":
    main()

-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 k >= z >= 0: -            ans += 1 -print(ans) +import sys + +input = sys.stdin.readline + + +def main(): +    K, S = list(map(int, input().split())) +    CNT = 0 +    for x in range(K + 1): +        for y in range(K + 1): +            if S - x - y >= 0 and S - x - y <= K: +                CNT += 1 +    print(CNT) + + +if __name__ == "__main__": +    main()