def resolve():

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

    count = 0

    for x in range(K + 1):

        for y in range(K + 1):

            if S - K <= x + y <= S and max(x, y) <= K:

                count += 1

    print(count)





if __name__ == "__main__":

    resolve()
def resolve():

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

    count = 0

    for x in range(K + 1):

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

            count += 1

    print(count)





if __name__ == "__main__":

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


if __name__ == "__main__":
    resolve()

def resolve():
    K, S = list(map(int, input().split()))
    count = 0
    for x in range(K + 1):
        for y in range(max(0, S - K - x), min(K + 1, S - x + 1)):
            count += 1
    print(count)


if __name__ == "__main__":
    resolve()

-        for y in range(K + 1): -            if S - K <= x + y <= S and max(x, y) <= K: -                count += 1 +        for y in range(max(0, S - K - x), min(K + 1, S - x + 1)): +            count += 1