n, goal_num = list(map(int, input().split()))

ans = 0

for x in range(n+1):

  for y in range(n+1):

    z = goal_num - x - y

    if 0 <= z <= n:

      ans += 1

print(ans)
n,m = list(map(int,input().split()))

cnt = 0

for i in range(n+1):

  for j in range(n+1):

    if m-i-j <= n and m-i-j >= 0:

      cnt += 1	

print(cnt)
n, goal_num = list(map(int, input().split()))
ans = 0
for x in range(n + 1):
    for y in range(n + 1):
        z = goal_num - x - y
        if 0 <= z <= n:
            ans += 1
print(ans)

n, m = list(map(int, input().split()))
cnt = 0
for i in range(n + 1):
    for j in range(n + 1):
        if m - i - j <= n and m - i - j >= 0:
            cnt += 1
print(cnt)

-n, goal_num = list(map(int, input().split())) -ans = 0 -for x in range(n + 1): -    for y in range(n + 1): -        z = goal_num - x - y -        if 0 <= z <= n: -            ans += 1 -print(ans) +n, m = list(map(int, input().split())) +cnt = 0 +for i in range(n + 1): +    for j in range(n + 1): +        if m - i - j <= n and m - i - j >= 0: +            cnt += 1 +print(cnt)