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



result = 0



for i in range(k+1):

    for j in range(k+1):

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

            result += 1



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



def fun(k, s):

    count = 0

    for i in range(k+1):

        for j in range(k+1):

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

                count += 1



    return count



print((fun(k, s)))
k, s = list(map(int, input().split()))
result = 0
for i in range(k + 1):
    for j in range(k + 1):
        if s - i - j <= k and s - i - j >= 0:
            result += 1
print(result)

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


def fun(k, s):
    count = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if s - i - j <= k and s - i - j >= 0:
                count += 1
    return count


print((fun(k, s)))

-result = 0 -for i in range(k + 1): -    for j in range(k + 1): -        if s - i - j <= k and s - i - j >= 0: -            result += 1 -print(result) + + +def fun(k, s): +    count = 0 +    for i in range(k + 1): +        for j in range(k + 1): +            if s - i - j <= k and s - i - j >= 0: +                count += 1 +    return count + + +print((fun(k, s)))