import itertools



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



count = 0

for x, y in itertools.product(list(range(k + 1)), repeat = 2):

    if x + y <= s <= x + y + k:

        count += 1



print(count)

import itertools



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



count = 0

for x in range(max(0, s - 2 * k), min(k + 1, s + 1)):

    count += min(s - x, 2 * k - (s - x)) + 1



print(count)

import itertools

k, s = list(map(int, input().split()))
count = 0
for x, y in itertools.product(list(range(k + 1)), repeat=2):
    if x + y <= s <= x + y + k:
        count += 1
print(count)

import itertools

k, s = list(map(int, input().split()))
count = 0
for x in range(max(0, s - 2 * k), min(k + 1, s + 1)):
    count += min(s - x, 2 * k - (s - x)) + 1
print(count)

-for x, y in itertools.product(list(range(k + 1)), repeat=2): -    if x + y <= s <= x + y + k: -        count += 1 +for x in range(max(0, s - 2 * k), min(k + 1, s + 1)): +    count += min(s - x, 2 * k - (s - x)) + 1