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



cnt = 0

for x in range(K+1):

    for y in range(K+1):

        z = S - y - x

        if 0 <= z <= K:

            cnt += 1



print(cnt)
def main():

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

    ans = 0

    for i in range(K+1):

        for j in range(K+1):

            tmp = i + j

            if 0 <= S - tmp <= K:

                ans += 1

    print(ans)



if __name__ == "__main__":

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

def main():
    K, S = list(map(int, input().split()))
    ans = 0
    for i in range(K + 1):
        for j in range(K + 1):
            tmp = i + j
            if 0 <= S - tmp <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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