# -*- coding: utf-8 -*-



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

count = 0



for x in range(0, K+1):

    for y in range(0, K+1):

        z = S - x - y

        if z < 0 or z > K:

            continue

        if x + y + z == S:

            count += 1



print(count)

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

c = 0

for x in range(K+1):

    for y in range(K+1):

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

            c += 1

print(c)

# -*- coding: utf-8 -*-
K, S = list(map(int, input().split()))
count = 0
for x in range(0, K + 1):
    for y in range(0, K + 1):
        z = S - x - y
        if z < 0 or z > K:
            continue
        if x + y + z == S:
            count += 1
print(count)

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

-# -*- coding: utf-8 -*- -count = 0 -for x in range(0, K + 1): -    for y in range(0, K + 1): -        z = S - x - y -        if z < 0 or z > K: -            continue -        if x + y + z == S: -            count += 1 -print(count) +c = 0 +for x in range(K + 1): +    for y in range(K + 1): +        if 0 <= (S - x - y) <= K: +            c += 1 +print(c)