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

ans = 0

for i in range(k+1):

  for j in range(k+1):

    if 0<=s-i-j<=k:

      ans+=1

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

ans = 0

for i in range(k+1):

  if k <=s-i<=2*k:

    ans+= k*2-s+i+1

  elif 0<=s-i<=k:

    ans+= s-i+1

print(ans)
k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            ans += 1
print(ans)

k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    if k <= s - i <= 2 * k:
        ans += k * 2 - s + i + 1
    elif 0 <= s - i <= k:
        ans += s - i + 1
print(ans)

-    for j in range(k + 1): -        if 0 <= s - i - j <= k: -            ans += 1 +    if k <= s - i <= 2 * k: +        ans += k * 2 - s + i + 1 +    elif 0 <= s - i <= k: +        ans += s - i + 1