peterverebics/CodeNet_Python_118 huggingface dataset:
K,S=map(int,input().split())
ans=0
for X in range(K+1):
	for Y in range(X,K+1):
		for Z in range(Y,K+1):
			if X+Y+Z==S:
				if X==0 and Y==0:
					ans=ans+3
				elif X==0:
					ans=ans+3
				else:
					ans=ans+1
print(ans)
k, s = map(int, input().split())

c = int(s / 3)
 
ans = (k - c) 

if ans == 0:
  print(1)
else:
  print(ans*3)
k,s=map(int,input().split(" "))
count=0
for i in range(k):
    for j in range(k):
        for k in range(k):
            if i + j + k == s:
                count += 1
                
print(count)
K,S=map(int,input().split())
ans=0
t=S//3
for x in range(K+1):
  if 0<=S-x and S-x<=2*K:
    ans+=1
print(ans*(ans+1)//2)
K, S = list(map(int, input().split()))

res = 0

for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 > z and z <= K:
      res += 1

print(res)
K, S = map(int, input().split())
res = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S- x + y
        if z>=0 and z<=K:
            res += 1
print(res)
K,S=map(int,input().split())
ans=1
a=max(0,S-2*K)
for i in range(a,K+1):
  if i>S:
    break
  for j in range(a,K+1):
    if i+j>S :
      break
    if S-i+j<=K :
      ans+=1

print(ans)
K, S = map(int, input().split())
count = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if S == x+y+z:
            count += 1

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


ans_ls = [0 for _ in range(K*3+1)]

for n in range(K+1):
  if n <= K:
    ans_ls[n] = (n+1)*(n+2)//2
    ans_ls[-1*n-1] = (n+1)*(n+2)//2

sum_ans = sum(ans_ls)

if K%2 == 0:
  ans_ls[(K//2)*3] = (K+1)**3-sum_ans
else:
  ans_ls[(K*3//2)] = ((K+1)**3-sum_ans)//2
  ans_ls[(K*3//2)+1] = ((K+1)**3-sum_ans)//2

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

ans = 0
for X in range(K+1):
    T = S-X
    if T <= K:
        ans += T+1
    else:
        ans += max(2*K-T+1,0)
print(ans)
k, s = map(int, input().split())
i = 0
x = 0
for x in range(0,k+1):
    for y in range(0,k+1-x):
        for z in range(0,k+1-x-y):
            p = x+y+z
            if x+y+z == s: i += 1

print(i)
def LI():
    return list(map(int, input().split()))


K, S = LI()
ans = 0
for i in range(K+1):
    total = S-i
    kosu = total+1
    if total > 2*K:
        continue
    if total > K:
        kosu -= (total-K)*2
        ans += kosu
    else:
        ans += kosu
print(ans)
k,s=map(int,input().split())
res=0
for x in range(k+1):
    for y in range(x,k+1):
        for z in range(y,k+1):
            if x+y+z==s:
                res+=1
print(res)
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  if i>S:
    break
  for j in range(K+1):
    if S-i+j<=K :
      ans+=1

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

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

if k*3==s:
  print(1)
  exit()

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

count=0
for x in range (k+1):
  for y in range(k+1):
    z = s - x - y
    if z < 0:
      continue
    count+=1
        
print(count)
# coding: utf-8
# Your code here!
import itertools


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

lst = [i for i in range(k+1)]


prod = itertools.product(lst, repeat=3)



ans = 0


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

ans_count = 0
for i in range(0, input[0]):
  for j in range(0, input[0]):
    for k in range(0, input[0]):
      if (i + j + k == input[1]):
        ans_count+=1
        
print(ans_count)
K, S = map(int, input().split())
count = 0
for x in range(K+1):
  for y in range(1,K+1):
    for z in range(1,K+1):
      print(x,y,z,x+y+z,S)
      if x + y + z == S:
        count = count + 1
print(count)
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    flg = False
    for j in range(K+1):
        if flg == True:
            break
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                flg = True
                cnt += (K+1 - j)
                break
print(cnt)
K,S = map(int, input().split())

if K == S:
	print( (K+5)*(K+4)//2 )
	exit() 

ans = 0
for X in range(K+1):
	S1 = S - X
	if S1 < 0:
		break
	else:
		if S1 <= K:
			ans += S1 + 1
		elif S1 <= 2 * K:
			ans += S1 - 2*K + 1
		else:
			continue

print(ans)
k, s = map(int, input().split(" "))
answer = 0

for i in range(k + 1):
    for j in range(k + 1):
        rem = 3 * k - i - j
        if 0 <= rem <= k:
            answer += 1
print(answer)
K,S=map(int,input().split())
ans=0
for i in range(K+1):
    for j in range(K+1):
        if (i+j)>S:
            break
        if (S-K)<=(i+j):
            break
        ans+=1

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

for i in range(k):
    for j in range(k):
        z = s - i - j
        if 0 <= z <= k:
            cnt += 1

print(cnt)
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0 or c ==0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num*3
    print(num)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(s-x-y):
            if 0<=z<=k and x+y+z==s:
              ans += 1
print(ans)
from math import *

def nHr(n, r):
   if 0 <= r:
      return factorial(n+r-1) / (factorial(r) * factorial(n-1))
   else:
      return 0

lst = input().split()
K = int(lst[0])
S = int(lst[1])

a = nHr(3, S)
b = (3 * nHr(3, S - K)) - (3 * nHr(3, S - (2*K)))

print(int(a - b))
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1-i):
    zz = i + j
    if zz > S:
      break
    for k in range(K+1-zz):
      z = i + j + k
      if z == S:
        #print(i,j,k)
        ANS+=1
      elif z >= S:
        break
print(ANS)
k, s = list(map(int, input().split()))

count = 0

for p in range(k+1):
    if p > s:
        break
    for q in range(k+1):
        if p + q < s:
            break
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1
                break

print(count)
k,s = map(int,input().split())
ans = 0
for i in range(k):
	for j in range(k):
		if 0 <= s - i - j <= k: ans += 1
		#elif s - i - j > k: break
print(ans)
K,S=map(int,input().split())

count=0

for A in range(2*K+1):
        for Z in range(K+1):
            if A+Z==S:
                count+=1

print(count*2)
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

for i in range(K + 1):
    for j in range(K + 1):
        if S - (i + j) <= K:
            r += 1

print(r)
import sys
in1 = sys.stdin.readlines()

#in1 = ['5 15']

K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if S - idx1 - idx2 <= K:
            RC += 1

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

print(count)
K, S = map(int, input().split())
x = S if K>S else K

ans = 0
for i in range(x+1):
  x1 = S-i
  for j in range((K if x1>K else x1)+1):
    x2 = S-i-j
    for k in range((K if x2>K else x2)+1):
      if i+j+k==S:
        print("{} {} {}".format(i,j,k))
        ans += 1
print(ans)
x,y = list(map(int, input().split()))
count=0
for i in range(x+1):
    for j in range(x+1):
        k=y-i-j
        if k<x and k>0:
          count+=1
print(count)
K,S = map(int, input().split())
count = 0
for i in range(K):
  for j in range(K-i):
    for k in range(K-i-j):
      if i + j + k == S:
        count += 1
print(count)
K,S=map(int,input().split())
N=0
for X in range(K+1):
    for Y in range(K+1):
            if X+Y<=S:
                N+=1
print(N)
(k, s) = list(map(int, input().split()))
count = 0
kmin = int(s / 3)
for x in range(kmin, k + 1):
    for y in range(kmin, k + 1):
        for z in range(kmin, k + 1):
            if s == x + y + z:
                count += 1
print(count)
k,s=map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x -y
        if z<0:
            break
        else:
            ans +=1
        
print(ans)
k, s = map(int, input().split())

ans = 0
for i in range(k + 1):
    rest = s - i
    if rest < 0:
        break
    elif rest > 2 * k:
        continue
    else:
        for j in range(k + 1):
            rest2 = rest - j
            if rest2 < 0:
                break
            elif rest2 > k:
                continue
            else:
                ans += k - rest2 + 1
                break

print(ans)
K, S = map(int, input().split())
c = 0
for x in range(K):
    for y in range(S - x):
        z = S - x - y
        if 0 <= z <= K:
            c += 1
print(c)
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1-x):
      if s-x-y>=0:
        count+=1
print(count)
K,S=map(int,input().split())
ans=0
c=0
if S%3==0:
  c=S//3
for x in range(K+1):
  if 0<=S-x and S-x<=2*K:
    ans+=1
print(ans*(ans+1)//2-2*c)
k,s = list(map(int,input().split()))
ans = 0
for i in range(k):
  for j in range(k):
    if 0 <= s-i-j <= k:
      ans += 1
print(ans)
K,S=map(int,input().split())
r=K+1
count=0
for x in range(r):
  if x>S:
    break
  for y in range(r):
    if y>S:
      break
    z=S-x-y
    if 0<=z and z<=r:
      count+=1
print(count)
k, s = map(int, input().split())
i = 0
x = 0
for x in range(0,k+1):
    for y in range(0,k+1-x):
        if x <= k & y <= k & s-x-y <= k & x+y <= s: i += 1 
#            if x+y+z == s: i += 1
print(i)
K, S = map(int, input().split())
count=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            if i+j+K == S:
                count +=1

print(count)
K,S = map(int,input().split())
res = 0
for x in range(K+1):
    for y in range(K+1):
        if S-x-y >= 0:
            res+=1
print(res)
k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(i, k + 1):
        for l in range(j, k + 1):
            x = i
            y = j
            z = l
            if i + j + l == s:
                count += 1
count *= 3
if s % 3 == 0:
    count = 1
else:
    count = count
print(count)
k,s = map(int,input().split())
count = 0
for x in range(k+1):
    for y in range(k+1-x):
        if 0<=s-x-y<=k:
            count+=1
print(count)
k, s = [int(i) for i in input().split()]

ans = 0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j >= 0:
      ans += 1
        
print(ans)
[K, S] = list(map(int, input().split()))
count = 0
total = 0
for X in range(K+1):
  if X > S:
    break
  for Y in range(K+1):
    add_xy = X + Y
    if S < add_xy and add_xy < (2/3) * S:
      break
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1
  if S < add_xy:
    break
      
print(count)
K, S = map(int, input().split())
c = 0
for x in range(K):
    if x > S:
        continue
    for y in range(S - x):
        z = S - x - y
        if 0 <= z <= K:
            c += 1
print(c)
k,s = map(int,input().split())
count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s-(x+y)
    if z>=0 and z<k:
      count += 1
print(count)
K,S=map(int,input().split())

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    if (S-K)<5:
        print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
    else:
        print(int((((S+1)*(S+2))/2)-3*(((5-1)*5)/2)-(S-K-5)*4))
K, S = map(int, input().split())
Y = 0

for i in range(K+1):
  for j in range(K+1):
    if S-i-j <= K:
      Y = Y+1

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

count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if k >= z and x + y + z == s:
            count += 1
            
print(count)
k,s = map(int,input().split())
f = 0
for i in range(k):
    for j in range(k):
        for l in range(k):
            if i+j+l==s:
                f+=1
print(f)
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1-i):
    if s-i-j<=k:
      ans+=1
print(ans)
N,K=map(int,input().split())
count=0
for i in range (K+1):
	for j in range (K+1):
		k=N-i-j
		if k>=0 and k<=K:
			count+=1
print(count)
K, S = map(int, input().split())
res = 0
for XY in range(2*K+1):
    Z = S - XY
    if Z in range(K+1):
        res += 1

print(res)
k, s = map(int, input().split())
count = 0
for a in range(k+1):
  for b in range(k+1):
      if a + b <= s:
        count += 1
      else:
        pass
print(count)
K, S = map(int,input().split())
ans = 0
for X in range(0,K+1):
    T = S-X
    if T <= 2*K:
        if K <= T:
            ans += K-(T-K)+1
        else:
            ans += T+1
print(ans)
K, S = list(map(int, input().split()))
ct = 0
for a in range(K+1):
    for b in range(K+1):
        if 0 <= a+b <= min(S,3*K-S):
            ct += 1
print(ct)
k, s = map(int, input().split())
res = 0

for x in range(k):
  for y in range(k):
    for z in range(k):
      if (x + y + z) == s:
        res += 1
        
print(res)
K, S = map(int, input().split())
ans = 0 
for X in range(S//3, K + 1):
    for Y in range(S//3, K + 1):
        for Z in range(S//3,K + 1):
            if X + Y + Z == S:
                ans += 1
print(ans)
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(s - x - k, min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)
K, S = map(int, input().split())
Sum = 0

for i in range((S // 3), K + 1):
    for j in range(i + 1):
        if 0 <= S - i - j <= K:
            if i == j:
                Sum += 1
            else:
                Sum += 2

print(Sum)
import sys
input = sys.stdin.readline

k, s = map(int, input().split())
cnt = 0
max_v = max(2 * (k + 2), s + 1)
memo = [0] * max_v
for i in range(k + 1):
  for j in range(k + 1):
    v = i + j
    if v > s:
      break
    memo[v] += 1
for i in range(k + 1):
  for j in range(max_v):
    v = i + j
    if v > s:
      break
    elif v == s:
      cnt += memo[j]
K,S = map(int,input().split())
ans = 0

for x in range(S+1):
    for y in range(S+1):
        for z in range(S+1):
            if x+y+z == S:
                ans+=1
print(ans)
K, S = map(int, input().split())
count = 0
for i in range(K+1):
  for j in range(K+1):
    if i + j <= S:
      count += 1
print(count)
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(x, k+1):
        z = s - x - y
        if z>=y and z<=k:
            tmp = set([x,y,z])
            if len(tmp)==3:
                ans += 6
            if len(tmp)==2:
                ans += 3
            else:
                ans += 1
print(ans)
k,s=map(int,input().split())
c=0
for x in range(k+1):
    for y in range(k+1):
            if s-x-y<=k:c+=1
print(c)
a,b=list(map(int,input().split()))
count=0
for x in range(a+1):
    for y in range(a+1):
        if b < x+y:
            break
            if b-x-y <= z:
                count+=1
print(count)
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i+2*a > b and i < b:
      for j in range(a+1):
        if i+j+a > b:
          for k in range(a+1):
            if i+j+k == b:
              ans += 1
              
  print(ans)
s,k=map(int,input().split())
print([x+y+z for x in range(0,k+1) for y in range(0,k+1) for z in range(0,k+1)].count(s))
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i + j + k == S:
                count = count + 1

print(count * 3)
K, S = map(int, input().split())

ans=0
for i in range(K+1):
    for j in range(K+1):
        if not S-i-j>K:
            ans+=1

print(ans)
k,s=map(int,input().split())
count=0
if s%3==0:
    count+=1
for i in range(0,s//2+1):
    if 0<=s-2*i<=k and i<=k and s-2*i!=i:
        count+=3
print(count)
for i in range(0,k-1):
    for j in range(i+1,k):
        if k>=s-i-j>j:
            count+=6
print(count)
k,s = map(int,input().split())
a = 0
for x in range(k+1):
  for y in range(x+1,k+1):
    for z in range(y+1,k+1):
      if x+y+z == s:
        if x != y and y != z and z != x:
          a += 6
        elif (x == y and y != z) or (x == z and z != y) or (z == y and y!= x):
          a += 3
        else:
          a += 1
        
print(a)
K, S = [int(i) for i in input().split()]
ans = 0
for i in range(K+1):
    for j in range(i, K+1):
        if 0 <= S-i-j <= K:
            ans += 1
print(ans)
k, s = map(int, input().split())
ans = 0

s3 = s // 3
m = max(k, s3)
for x in range(0, m + 1):
    print(x)
    for y in range(0, m + 1):
        ad = s - x - y
        if ad <= k and ad >= 0:
            ans += 1

print(ans)
n,m = map(int,input().split())
cnt = 0
for i in range(n+1):
  for j in range(n+1):
    if m-i+j <= n:
      cnt += 1	
print(cnt)
K,S=map(int,input().split())
ans = 0
z = 0
for x in range(K):
    for y in range(K):
        z = S - x - y
        if z >= 0 and z <= K:
            ans += 1
print(ans)
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(b+1):
  for k in range(b+1):
    if a<=i+k<=a+b:
      c=c+1
print(c)
s,t=map(int,input().split())
ans=0
for i in range(1,s+1,1):
  for j in range(1,s+1,1):
    if not s<t-i-j:
      ans+=1
print(ans)
k,s=map(int,input().split())
cnt=0
for x in range(k):
  for y in range(k):
    z=s-x-y
    if z>=0 and z<=2500:
      cnt+=1
        
print(cnt)
k, s = map(int, input().split())
ans = 0

for x in range(0, k+1):
    for y in range(0, k+1):
          if ((x + y + (s-x-y)) == s) and (s-x-y >= 0):
              ans+=1

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

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            print(x,y,z)
            cnt=cnt+1
        else:
            continue
    
print(cnt)
s,k=map(int,input().split())
print(len([1 for x in range(0,k+1) for y in range(0,k+1) if 0<=s-x-y<=k]))
#91 B - Sum of Three Integers
K,S = map(int,input().split())

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

count=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+K == S:
                count +=1

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

count = 0
for i in range(K):
  for j in range(K):
    for l in range(K):
      if i+j+l == S:
        count += 1

print(count)
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  for y in range(b+1):
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(s-x-y):
           if x+y+z==s:
               ans += 1
print(ans)
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    m = S-x
    if (m == 0 or m == 2*K):
        res += 1
    elif (m > 0 and m < 2*K):
        res += m + 1
print(res)
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

for i in range(K + 1):
    for j in range(K + 1):
        if i + j <= S:
            r += 1

print(r)
import sys
input = sys.stdin.readline

def main():
    k, s = map(int, input().split())
    vals = [x + y + z for x in range(k+1) for y in range(k+1) for z in range(k+1) if x + y + z == s]
    print(len([vals]))

if __name__ == '__main__':
    main()
# coding: utf-8
# Your code here!


ans = 0


print(ans)
K, S = map(int, input().split())
x = S if K>S else K

print(3+sum(range(3,3+(x-1))))
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s -(x+y)
        if z <= k:
            ans += 1
print(ans)
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    for l in range(k+1):
        z = s - i - l
        if z <= k:
            count += 1

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

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x + y <= k:
            ans += 1

print(ans)
K,S = map(int,input().split())
if S == 0:
  print(1)
  exit()
z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    if (S-i) % 2 == 0:
      z -= 1
      o += 1
    if num > 1 and min(S-i,i) == i:
      z -= 1
      o += 1
if S % 3 == 0:
  t += 1
  o -= 1
print(z*6 + o*3 + t)
K, S = map(int, input().split())

count = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if z >= 0:
      count += 1

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

count = 0
for x in range(K+1):
    if S-x<=2*K:
        for y in range(K+1):
            if S-x-y<=K:
                count += 1
#                 for z in range(K+1):
#                     if x+y+z==S:
#                         count += 1
print(count)
K,S = map(int, input().split())
count = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      if i + j + k == S:
        count += 1
print(count)
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = s-x-y
    ans += (z and z <= k)
print(ans)
K, S = map(int, input().split())
pattern = 0
for i in range (0,K+1):
  for j in range (0,K+1):
    if S - (i) - j >= 0:
      pattern += 1
print(pattern)
x,y = list(map(int, input().split()))
count=0
for i in range(1,x+1):
    for j in range(1,x+1):
        for k in range(1,x+1):
            a=i+j+k
            if y==a:
                count+=1
print(count)
k,s = map(int,input().split())
ans = 0
if s>3*k:
    print(0)
elif s-k<=0:
    for i in range(s+1,0,-1):
        print(i)
        ans += i
else:
    for i in range(k+1):
        for j in range(k+1):
            if s-k<=i+j<=s: 
                ans += 1
print(ans)
K,S = (int(x) for x in input().split())
count = 0

for x in range(K+1):
    if x > S:
        break
    for y in range(K+1):
        if x + y > S:
            break
        for z in range(K+1):
            #print(x,y,z)
            if x + y + z == S:
                count += 1
                print(x,y,z)


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

s3 = s // 3
m = min(k, s3)
for x in range(m, 0, -1):
    print(x)
    for y in range(m, 0, -1):
        for z in range(s - x - y, 0, -1):
            xyz = x + y + z
            if x + y + z == s:
                ans += 1
            elif xyz < s:
                break

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

ans = 0

for x in range(0, K + 1):
    for y in range(0, K + 1):

        z = S - x - y
        if z <= K and z > 0:
            ans += 1

print(ans)
def main():
    k, s = list(map(int, input().split()))
    if k*3 == s:
        print(1)
        exit()
    else:
        print(k*3)

if __name__ == '__main__':
    main()
k,s = map(int,input().split())

ans = 0
if(s == 0):
  print(1)
  exit()
elif(s == 3*k):
  print(1)
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z <= 0 and z >= k):
      ans += 1
        
print(ans)