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

answer = 0



for x in range(K+1):

  for y in range(K+1):

    if S - x - y <= K and S -x-y >=0:

      answer += 1

 

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



count = 0

for x in range(k+1):

	for y in range(k+1):

		if 0 <= s - x - y <= k:

			count += 1



print(count)

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

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

-K, S = list(map(int, input().split())) -answer = 0 -for x in range(K + 1): -    for y in range(K + 1): -        if S - x - y <= K and S - x - y >= 0: -            answer += 1 -print(answer) +k, s = list(map(int, input().split())) +count = 0 +for x in range(k + 1): +    for y in range(k + 1): +        if 0 <= s - x - y <= k: +            count += 1 +print(count)