# ABC051B - Sum of Three Integers

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

count = 0

for i in range(k + 1):

    for j in range(k + 1):

        if 0 <= s - i - j <= k:

            count += 1

print(count)
# ABC051B - Sum of Three Integers

def main():

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

    ans = 0

    for x in range(K + 1):

        for y in range(K + 1):

            z = S - x - y

            if z < 0:

                break

            if z <= K:

                ans += 1

    print(ans)





if __name__ == "__main__":

    main()
# ABC051B - Sum of Three Integers
k, s = list(map(int, input().rstrip().split()))
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1
print(count)

# ABC051B - Sum of Three Integers
def main():
    K, S = tuple(map(int, input().split()))
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if z < 0:
                break
            if z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-k, s = list(map(int, input().rstrip().split())) -count = 0 -for i in range(k + 1): -    for j in range(k + 1): -        if 0 <= s - i - j <= k: -            count += 1 -print(count) +def main(): +    K, S = tuple(map(int, input().split())) +    ans = 0 +    for x in range(K + 1): +        for y in range(K + 1): +            z = S - x - y +            if z < 0: +                break +            if z <= K: +                ans += 1 +    print(ans) + + +if __name__ == "__main__": +    main()