peterverebics/CodeNet_Python_118 huggingface dataset:
n, y = map(int, input().split())

man = y//10000

ans = 0
for i in range(man+1):
  mansatsu = i*10000
  for j in range(n-i+1):
    temp = mansatsu + j*5000
    if y - temp == 1000*(n-(i+j)):
      print(i,j,n-(i+j))
      ans = 1
      break
if ans == 0:
  print("-1 -1 -1")
n,y=input().split()
if int(y)%1000:print('-1 -1 -1')
else:print('0 0 %d'%(int(y)/1000))
import sys
def myAnswer(N:int,Y:int) -> None:
   for i in range(N+1):
      for j in range(N+1-i):
         if(10000*i + 5000*j + 1000*(N-i+j)==Y):
            print(i,j,(N-i+j))
            sys.exit()
   print(-1,-1,-1)

def modelAnswer():
   return
def main():
   N,Y = map(int,input().split())
   myAnswer(N,Y)
if __name__ == '__main__':
   main()
n,y = map(int, input().split())

a = -1
b = -1
c = -1
n1 = y // 10000
n2 = y // 5000
for i in range(n1+1):
    for j in range(n2+1-i):
        money = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if y == money:
            a = i
            b = j
            c = n - i - j
            break;


print(str(a)+" ",str(b)+" ",str(c))
n,y=map(int,input().split());print(*([(i,j,n-i-j)for i in range(n+1)for j in range(9)if 9*i+4*j+n==y/1e3]+[(-1,-1,-1)])[0])
n,m = map(int,input().split())
total = 0

for a in range(n+1):
  for b in range(n+1):
    total=10000*a+5000*b+1000*(n-a-b)
    if total == m:
      print(a,b,n-a-b)
      exit()
    
print(-1,-1,-1)
n, y = map(int,input().split())
a=-1
b=-1
c=-1
for i in range(n):
    for j in range(n-i):
        total = i*10000+j*5000+(n-i-j)*1000
        if total==y:
            a=i
            b=j
            c=n-i-j
            
            
print(a,b,c)
n, y = map(int, input().split())

for nx in range(n+1):
   for ny in range(n-nx+1):
      if (1000 * nx + 5000 * ny + 1000 * (n - nx - ny) == y):
         print(nx, ny, n - nx - ny)
         exit()

print(-1, -1, -1)
# ans

N, Y = map(int, input().split())

for a in range(N):
  for b in range(N):
    c = N - a - b
    if 10000 * a + 5000 * b + 1000 * c == Y and a + b + c == N:
      print(a,b,c)
      exit()
        
print(-1,-1,-1)
n, y = map(int, (input().split()))
 
for i in range(n+1):
  for j in range(n+1):
    for k in range(n+1):
      if 10000*i + 5000*j + 1000*k == y:
        print(i, j, k)
        break
else:
  print(-1, -1, -1)
s = input().split()
N = int(s[0])
Y = int(s[1])

for a in range(N + 1):
    for b in range(N + 1):
        for c in range(N - a - b + 1):
            if a * 10000 + b * 5000 + c * 1000 == Y:
                print(str(a) + " " + str(b) + " " + str(c))
                exit(0)

print("-1 -1 -1")
n,y = map(int,input().split())

ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        #for k in range(n+1-i-j):
        d = y - (i * 10000 + j * 5000)
        if d >= 0 and d % 1000 == 0 and d//1000 < n + 1 - i - j:
            ans = '{} {} {}'.format(i,j,d//1000)
            break
print(ans)
n,y = map(int,input().split())
count = 0
for a in range(2001):
  for b in range(2001):
    c = n - a - b
    if 10000*a + 5000*b + 1000*c == y and 0 <= c <= 2000:
      print(str(a) + " " + str(b) + " " + str(c))
      count += 1
      break
  if count == 1:
    break
import sys
#N枚のお金N，合計金額Y
N, Y = map(int, input().split())

"""
a = 0 #1000円札の枚数
b = 0 #5000円札の枚数
c = 0 #10000円札の枚数

X = 0 #合計金額
"""

for a in range(N+1):
    for b in range(N-a+1):
        X = 1000*a + 5000*b + 10000*(N-a-b)
        if X == Y:
            print(a, b, N-a-b)
            sys.exit()


print("-1 -1 -1")
N,X = map(int,input().split())
l = []
bo = 0
for a in range(N+1):
    for b in range(N-a+1):
        if a*10000 + b*5000 + (N-a-b)*1000 == X:
            print(a,b,N-a-b)
            bo+=1
            break
        break
if bo==0:
    print('-1 -1 -1')
[N,Y] = list(map(int,input().split(' ')))

t = int(Y/1000 - N)
x = -1
y = -1
z = -1
for i in range(N):
  if (int((t - 9*i)/4) == (t - 9*i)/4):
    x = i
    y = int((t - 9*i)/4)
    z = N - x - y
    break
  elif ((t - 9*i)/4 < 0):
    break
  else:
    continue
    
print('{0} {1} {2}'.format(x,y,z))
n, result = map(int, input().split())

for x in range(n + 1):
  for y in range(n - x + 1):
    if x + y + (n - x - y) == 9:
      if 10000 * x + 5000 * y + 1000 * (n - x - y) == result:
        print(x, y, (n - x - y))
        exit()

print("-1,-1,-1")
N,Y = map(int, input().split())
for x in range(1,N+1):
    for y in range(1,N+1):
        if 0 <= Y - x - y < Y:
            print(x,y,Y-x-y)
            exit()
print("-1 -1 -1")
N,Y = map(int,input().split())


for x in range(0,N+1):

  for y in range(0,N+1-x):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y:
      break
      
  if 10000*x + 5000*y + 1000*z == Y:
    break
  else:
    x=-1
    y=-1
    z=-1
a,b = map(int,input().split())
for i in range(a+1):
    for j in range(a-i+1):
        z = a-i-j
        if 10000*i+5000*j+1000*z==b and 1<=z<=2000:
            print(i,j,z)
            exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

Y //= 1000

for y in range(9):
  Y -= 5 * y
  N -= y
  x, p = divmod(Y - N, 9)
  z, q = divmod(10*N - Y, 9)
  if p == 0 and q == 0 and x >= 0 and z >= 0:
    print(x, y, z)
    exit()

print(-1, -1, -1)
import sys
n,y = map(int,input().split())

for i in range(n):
    for j in range(n-i):
        for k in range(n-i-j):
            if (10000*i+5000*j+1000*k == y):
                print(i,j,k)
                sys.exit()
print('-1 -1 -1')
N, Y = map(int, input().split())

for x in range(N+1):
    for y in range(N):
        if 10000*x + 5000*y + 1000*(N-(x+y)) == Y and N-(x+y) >= 0:
            print(x, y, N-(x+y))
            exit()

print(-1,-1,-1)
n,y = map(int,input().split())
lst = []
ans = 0
for i in range(y//10000+1):
    for j in range(y//5000+1):
        k = (y - 10000*i - 5000*j)//1000
        if k >= 0 and 0< i+j+k <= n:
            lst.append([i,j,k])
            ans += 1
if ans > 0:
    print(*lst[0])
else:
    print('-1 -1 -1')
n,y = [int(i)  for i in input().split()]
#c3 = int(y%5000/1000)
#print(c3)
#y -= c3*1000
#n -= c3
for i in range(2001):
  for j in range(2001):
    if 10000*(i)+5000*(j)+1000*(n-i-j) == y:
      print(i,j,n-i-j)
      exit()
print(-1,-1,-1)
def resolve():
    N, Y = map(int, input().split())

    resx, resy, resz = (-1, -1, -1)
    xn = Y//10000
    for x in range(xn+1):
        yn = (Y-10000*x)//5000
        for y in range(yn+1-x):
            z = N - x - y
            total = 10000*x + 5000*y + 1000*z

            if total == Y:
                resx, resy, resz = (x, y, z)
                break
    
    print(resx, resy, resz)

resolve()
def solve(args):
    n, y = args
    #.
    y = y // 1000

    #.
    for i in range(n+1):
        for j in range(n+1):
            #.
            money = y - i*10 - j*50

            #.
            if money == n - i - j:
                return "{} {} {}".format(i, j, money)

    return "-1 -1 -1"
    
print(solve(map(int, input().split())))
[N,Y] = list(map(int,input().split(' ')))

t = int(Y/1000 - N)
x = -1
y = -1
z = -1
for i in range(min(N+1, int(t/9))):
  if ((t - 9*i)/4 < 0):
    break
  elif (int((t - 9*i)/4) == (t - 9*i)/4) and (N - i - int((t - 9*i)/4) >= 0) and (t - 9*i)/4 >= 0:
    x = i
    y = int((t - 9*i)/4)
    z = int(N - x - y)
    break
  else:
    continue
    
print('{0} {1} {2}'.format(x,y,z))
def main():
	N,Y = map(int,input().split())
#	ListN = [N-i for i in range(N+1)]
	for a in range(N+1):
		for b in reversed(range(N+1-a)):
			c,mody = divmod(10000*a+5000*b,1000)
			if c <= N-a-b and mody == 0:
				print(a,b,c)
				exit()
	print(-1,-1,-1)

if __name__ == '__main__':
	main()
N,Y = map(int, input().split())
Y2 = Y//1000 - N
a = Y2 % 4
b = (Y2 - 9 * a) // 4
c = N - a - b
if c < 0: a+=(c//5)*-5; b-=(c//5)*-10; c+=(c//5)*-5
if b < 0:
    a+=b; b=0
    if 10*a+5*b+c != Y and a >= 0:
        sub = 10*a+c - Y // 1000
        a -= sub//5; b += sub // 5
if a < 0 or b < 0: a=-1; b=-1; c=-1
print(a, b, c)
N, Y =map(int, input().split())
X = [-1,-1,-1]
for i in range(2000):
  y = (Y-1000*N-9000*i)/4000
  if not float.is_integer(y):
    continue
  if 0<= N-i-y <= 2000:
    X=[N-i-y, y, i]
    X=list(map(int, X))
    break
print(*X)
N, Y = map(int, input().split())
for i in range(Y // 10000 + 1):
  for j in range(Y - 10000 * i // 5000 + 1):
    if 10000 * i + 5000 * j == Y - 1000 * (N - i - j):
      print(i, j, N - i - j)
      exit()
print(-1, -1, -1)
N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N+1-x):
        if x*10000 + y*5000 + (N-x-y)*1000 == Y:
           print(x, y, N+1-x-y)
           exit()
 
print(-1,-1,-1)
from itertools import product
N,Y=map(int, input().split())

def total_check(n, y):
    for b in range(N+1):
        for a in range(N+1):
            if a + b > N:
                break
            c = N - a - b
            t = 10000 * a + 5000 * b + 1000 * c
            print(t)
            if t==y:
                return a, b, c
    return -1,-1,-1
a,b,c=total_check(N,Y)
print(a,b,c)
n,Y=map(int,input().split())
cnt=0
for x in range(n+1):
  for y in range(n+1):
    z=n-x-y

 
    if 10000*x+5000*y+1000*z==Y:
      print('{} {} {}'.format(x,y,z))
      cnt+=1
      break
  break
      
    
if cnt==0:
  print('{} {} {}'.format(-1,-1,-1))
N,Y = list(map(int,input().split()))
for i in range(0,N+1):
    for j in range(0,N+1):
        if i*10000+j*5000+(N-i-j)*1000 == Y:
          print('{0} {1} {2}'.format(i,j,N-i-j))
          exit()
print('-1 -1 -1')
n, y = map(int, input().split())
a={}
j=True
if y % 1000 != 0 or y // 10000 > n:
    print(-1, -1, -1)

for th in range(0, n+1) :
    for fh in range(0, n-th+1) :
        if th * 10000 + fh * 5000 + (n-fh-th) * 1000 == y :
            print (th, fh, n-fh-th)
            j = False
            break

if j == True:
    print(-1, -1, -1)
N, Y = map(int, input().split())
 
for x in range (N+1):
  for y in range (N+1-x):
    z=N-x-y
    if 10000*x+5000*y+1000*z==Y:
    	print(x,y,z)
    else:
        print(-1,-1,-1)
N,Y=map(int,input().split())
flag=0

for x in range(N+1):
  if flag==1:
    break
  for y in range(N+1-x):
    if flag==1:
      break
    for z in range(N+1-x-y):
      money=10000*x+5000*y+1000*z
      if money == Y:
        print(x," ",y," ",z)
        flag=1
        break
        
if flag==0:
  print("-1 -1 -1")
n, y = map(int, input().split())

for i in range(n+1):
  for j in range(i, n+1):
    res = y - (10000*i + 5000*j)
    if res == 1000*(n - i - j):
      print(i, j, n-i-j)
      exit()
      
print('-1 -1 -1')
N,Y = map(int,input().split())
a = Y // 10000; b = Y // 5000; c = 0
for i in range(a+1):
    for j in range(b+1):
        c = ((Y-(10000*i+5000*j))/1000)
        if c.is_integer and c >= 0 and i+j+c == N:
            d = int(c)
            print(i,j,d)
            exit()
if c.is_integer==False:
    print(-1,-1,-1)
n ,y = map(int,input().split())
list = [-1,-1,-1]

for i in range(n+1):
    for j in range(n+1 - i):
        for k in range(n + 1 - i - j):
            if (k *10000 + j * 5000 + i* 1000) == y:
                list = [i,j,k]

                break
        if (k *10000 + j * 5000 + i* 1000) == y:
            break
    if (k *10000 + j * 5000 + i* 1000) == y:
        break
print(list[2],list[1],list[0])
def main():
	N,Y = map(int,input().split())
#	ListN = [N-i for i in range(N+1)]
	for a in range(N+1):
		for b in range(N+1-a):
			c,mody = divmod(Y-10000*a-5000*b,1000)
			if c <= N-a-b and mody == 0:
				print(a,b,c)
				exit()
	print(-1,-1,-1)

if __name__ == '__main__':
	main()
a,b=map(int,input().split())
ans=[]
for i in range(a+1):
    for j in range(a+1):
        k=(b-(i*10000+j*5000))//1000
        if 0<=i+j+k<=a and k>=0:
            ans.append([i,j,k])
            break

if ans==[]:
    print(-1,-1,-1)
else:
    print(ans[0][0],ans[0][1],ans[0][2])
n, y = map(int, input().split())

ans = 0
for x in range(n+1):
  for p in range(n+1):
    z = n - x - p
    if z >= 0:
      if y-10000*x-5000*p == 1000*z and x+p+z == y:
        print(x, p, z)
        ans += 1
    break

if ans == 0:
  print(-1, -1, -1)
n, y = map(int, input().split())

for i in range(n):
    for j in range(n-i):
        if 1000*i + 5000*j + 10000*(n-i-j) == y:
            print(n-i-j, j, i)
            exit()
print(-1, -1, -1)
N, Y = map(int, input().split())
res = -1, -1, -1

for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if 10000 * x + y * 5000 + z * 1000 == Y:
            res = x, y, z

print(res)
N, Y = map(int, input().split())

for i in range(0, N+1):
  for j in range(0, N+1-i):
    k = N - i - j
    if 10000*i + 5000*j + 1000*k == Y:
      break
      
print(i, j, k)
N, Y = map(int, input().split())
for i in range(N):
    if 10000 * i > Y:
        continue
    for j in range(N - i):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print(i, j, k)
            exit()
else:
    print(-1, -1, -1)
import sys
input = sys.stdin.readline
N, Y = map(int, input().strip("\n").split())
for x in range(N):
    for y in range(N - x):
        remainder = Y - 10000 * x - 5000 * y
        if (N - x - y) * 1000 == remainder:
            print(" ".join([str(x), str(y), str(N - x - y)]))
            exit(0)
print("-1 -1 -1")
N, Y = map(int, input().split())

a = 0

for i in range(N):
    for ii in range(N):
        for iii in range(N):
            ans = 10000 * i + 5000 * ii + 1000 * iii
            J = i + ii + iii
            if ans == Y and J == N:
                print(i,ii,iii)
                a += 1
                break
        if a != 0:
            break
    if a != 0:
        break

if a == 0:
    print(-1,-1,-1)
n,y = map(int, input().split())
a = []
for i in range(0,n,1):
  for j in range(0,n,1):
    if 9000*i+4000*j == y-1000*n and n-i-j >= 0:
      a = [i,j,n-i-j]
if a == []:
  print(-1,-1,-1)
else:
  print(a[0],a[1],a[2])
N,Y = map(int, input().split())
for x in range(N+1):
    y = ((Y-10000*x)-1000*(N-x))/5000
    z = N-y-x
    if 0<=y and 0<=z and 10000*x+5000*y+1000*z==Y:
        print (int(x),int(y),int(z))
        break
else:
    print("-1 -1 -1")
n,y = map(int,input().split())
ans = (-1,-1,-1)
for i in range(n+1): 
	for j in range(n+1-i):
		if y == 1000*(i + j * 5 + (n+1-i-j) * 10 ): 
			print(i, j, n+1-i-j)
			exit()
print(-1,-1,-1)
n,y = map(int,input().split())
ans = (-1,-1,-1)
for i in range(n+1): 
	for j in range(n+1-i):
		if y == 1000*(i + j * 5 + (n-i-j) * 10 ): 
			print( n+1-i-j, j, i ) # 逆だった。出力は10000から出す
			exit(0)
print(-1,-1,-1)
N, Y = list(map(int, input().split()))
results = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N - x + 1):
        if Y == 10000 * x + 5000 * y + 1000 * (N - x - y):
            results = [x, y, (N - x - y)]
print(results)
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(int(b/10000)+1):
  for k in range(int(b/5000)+1):
    if i*10000+k*5000+(a-i-k)*1000==b and (a-i-k)>=0:
      c=c+1
      break
if c==0:
  print(-1,-1,-1)
else:
  print(i,k,a-i-k)
N,Y = map(int,input().split())

flag = 0
for i in range(N+1):
    for j in range(N-i+1):
        for k in range(N-i-j+1):
            dama = 10000*i + 5000*j + 1000*k
            if dama == Y:
                print(str(i)+" "+str(j)+" "+str(k))
                flag = 1
                break
        else:
            continue
        break
    else:
        continue
    break

if flag == 0:
    print("-1 -1 -1")
import sys

K, S = map(int, sys.stdin.readline().strip().split())

N_MAX = min(K, S)

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

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

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

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

count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - (i + j) <= 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 in range(K+1):
            count+=1

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

for x in range(min(k,s)+1):
    for y in range(min(k,s)+1):
        if 0 <= s - x - y <= min(k,s):
            ans += 1
    
print(ans)
k,s=map(int,input().split())
ans=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      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 0 <= (S-x-y) <= K:
            c += 1
print(c)
K, S = map(int, input().split())

count = 0

for i in range(K + 1):
    for j in range(K + 1):

        if 0 <= S - i - j <= K:
            count += 1
print(count)
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())

count=0
for i in range(k+1):
  for j in range(k+1):
    if (s-(i+j)<=k)&(s-(i+j)>=0):
      count+=1
print(count)
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):
            cnt+=1
print(cnt)
K, S = [int(i) for i in input().split()]

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

cnt = 0
for l in range(k+1):
  for m in range(k+1):
    n = s - l - m
    if 0 <= n <= k:
      cnt += 1
print(cnt)
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        if((S-i-j)<=K and 0<=S-i-j):
            count=count+1
print(count)
K, S = list(map(int, input().split()))
cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= S - x - y <= K:
            cnt += 1
print(cnt)
k,s = map(int,input().split())
cnt=0
for i in range(k+1):
    for j in range(k+1):
        if s-k<=i+j<=s:
            cnt+=1
print(cnt)
#!/usr/bin/env python

def main():
    k, s = list(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 and z <= k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <= K:
            cnt += 1
print(cnt)
k, s = map(int, input().split())
ans = 0
for a in range(k+1):
    for b in range(k+1):
        if 0 <= s - a - b <= 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):
        if 0 <= S-(X+Y) <= K:
            ans += 1
print(ans)
K,S = map(int,input().split())
count = 0
for x in range(0,K+1):
  for y in range(0,K+1):
    if (S - (x + y) <= K and S - (x + y) >= 0):
      count += 1
print(str(count))
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)
K, S=map(int, input().split())
s=S-2*K if S-2*K>0 else 0
e=S if S<K else K
ans=0
for Z in range(s, e+1):
  if S-Z>K:
    ans+=2*K+Z-S+1
  else:
    ans+=S-Z+1
print(ans)
K,S = map(int,input().split())
ans = 0
for k in range(K+1):
    ans += max(0, min(S - k, K) - max(0, S - k - K) + 1)
print(ans)
[K, S] = list(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:
      cnt += 1
    else:
      continue
print(cnt)
k, s = map(int, input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0 <= s-z-y <= k]))
N,M=map(int,input().split())
counter=0
for a in range(N+1):
  for b in range(N+1):
    if 0<=M-(a+b)<=N:
      counter+=1
print(counter)
k,s=map(int,input().split())
ans=0
for i in range(0,k+1):
    for j in range(0,k+1):
        if 0 <= s-i-j <= k:
            ans += 1
print(ans)
K, S = map(int, input().split())

count=0
for i in range(0, K+1):
    for j in range(0, K + 1):
        if 0 <= S-i-j <= K:
            count+=1
print(count)
k,s=map(int,input().split())
ans=0
for x in range(k+1):  #xは 0~kまで  x=0,1,2,.....k
  for y in range(x,k+1): #yはx~k+1まで, 
    z = s-(x+y)  #zはxとyできまる, このときxyzの組み合わせが確定して評価する.
    if z>k or z<y:
      continue
    if x == y and y == z: #x=y=z
      ans+=1
    elif x==y or y == z or z==x:
      ans+=3
    else:
      ans+=6


print(ans)
def resolve():
    K, S = map(int, input().split())
    count = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - K <= x + y <= S and max(x, y) <= K:
                count += 1
    print(count)


if __name__ == "__main__":
    resolve()
a = input()
k, s = a.split(' ')
K = int(k)
S = int(s)
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if (z >= 0) and (z <= 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 0 <= z and z <= k:
            count += 1

print(count)
x = list(map(int,input().split()))
count=0
for a in range(max(0,x[1]-2*x[0]),min(x[0],x[1])+1):
    for b in range(max(0,x[1]-a-x[0]),min(x[0],x[1]-a)+1):
        for c in range(max(x[1]-a-b,0),min(x[1]-a-b,x[0])+1):
            if(a+b+c==x[1]):
                count+=1
print(count)
K, S = map(int, input().split())
Y = 0

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

print(Y)
k,s = map(int, input().split())
c=0
for i in range(k+1):
	for j in range(k+1):
		if s>=i+j and k+1+i+j>s :
			c+=1
			# print( c )

print( c )
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 and z >= 0 :
                ans += 1

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

print(count)
K, S = map(int, input().split())
s = 0
for x in range(min(S,K)+1):
  for y in range(min(S-x,K)+1):
    if S-x-y<=K:
      s += 1
print(s)
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 (0 <= z <= k):
            count += 1
                
print(count)
k,s = list(map(int, input().split()))
cnt=0
for i in range(k+1):
    for j in range(k+1):
        if s>=i+j>=s-k:
            cnt+=1
print(cnt)
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    if s-i>2*k:
        continue
    else:
        for j in range(k+1):
            if s-i-j>k or s-i-j<0:
                continue
            else:
                ans+=1
print(ans)
def actual(K, S):
    count = 0

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

            if 0 <= z <= K:
                count += 1

    return count

K, S = map(int, input().split())
print(actual(K, S))
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)
K, S = 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)
def resolve():
    K, S = 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)
resolve()
K, S = map(int, input().split())

l = max(S-K*2, 0)
h = min(K, S)

res = 0
for i in range(l, h+1):
    x = S-i
    ll = max(x-K, 0)
    hh = min(h, x)
    res += hh-ll+1

print(res)
k, s = [int(w) for w in 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())
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)