K, S = list(map(int, input().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)
K, S = list(map(int, input().split()))

count = 0

for i in range(K + 1):

    if 0 <= S - i < K:

        count += S - i + 1

    elif K <= S - i <= 2 * K:

        count += 2 * K - S + i + 1

    else:

        continue

print(count)
K, S = list(map(int, input().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)

K, S = list(map(int, input().split()))
count = 0
for i in range(K + 1):
    if 0 <= S - i < K:
        count += S - i + 1
    elif K <= S - i <= 2 * K:
        count += 2 * K - S + i + 1
    else:
        continue
print(count)

-    for j in range(K + 1): -        if 0 <= S - i - j <= K: -            count += 1 +    if 0 <= S - i < K: +        count += S - i + 1 +    elif K <= S - i <= 2 * K: +        count += 2 * K - S + i + 1 +    else: +        continue