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

count = 0

for X in range(K+1):

    for Y in range(K+1):

        if S-X-Y >= 0 and S-X-Y <= K:

            count += 1

print(count)
import sys

readline = sys.stdin.readline



def main():

    K, S = list(map(int, readline().rstrip().split()))

    ans = 0

    for x in range(K+1):

        for y in range(K+1):

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

                ans += 1



    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(K + 1):
        if S - X - Y >= 0 and S - X - Y <= K:
            count += 1
print(count)

import sys

readline = sys.stdin.readline


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