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

ct = 0

for X in range(K+1):

  for Y in range(K+1):

    if S - (X + Y) >= 0 and S - (X + Y) <= K :

        ct += 1 



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

ans = 0

for Z in range(K+1):

  r = S - Z

  if r < 0:

    ans += 0

  elif r <= K:

    ans += r+1

  elif r <= K*2:

    ans += (K+1)*2 - (r+1)

print(ans)
K, S = list(map(int, input().split()))
ct = 0
for X in range(K + 1):
    for Y in range(K + 1):
        if S - (X + Y) >= 0 and S - (X + Y) <= K:
            ct += 1
print(ct)

K, S = list(map(int, input().split()))
ans = 0
for Z in range(K + 1):
    r = S - Z
    if r < 0:
        ans += 0
    elif r <= K:
        ans += r + 1
    elif r <= K * 2:
        ans += (K + 1) * 2 - (r + 1)
print(ans)

-ct = 0 -for X in range(K + 1): -    for Y in range(K + 1): -        if S - (X + Y) >= 0 and S - (X + Y) <= K: -            ct += 1 -print(ct) +ans = 0 +for Z in range(K + 1): +    r = S - Z +    if r < 0: +        ans += 0 +    elif r <= K: +        ans += r + 1 +    elif r <= K * 2: +        ans += (K + 1) * 2 - (r + 1) +print(ans)