peterverebics/CodeNet_Python_118 huggingface dataset:
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    m = S-x
    if m == 0:
        res += 1
    if (m > 0 and m < 2*K):
        res += m + 1
    if m == 2*K:
        res += 1
print(res)
K,S = map(int,input().split())
alist = [i+j+h==S for i in range(0,K+1) for j in range(0,K+1) for h in range(0,K+1)]
print(len(alist))
def main():
	K,S = map(int,input().split())
	ans = 0
	ListK = [i+1 for i in range(K)]
	for x in ListK:
		for y in ListK:
			if S - (x + y) <= K:
				ans += 1
	print(ans)

if __name__ == '__main__':
	main()
k,s=map(int,input().split())
ans=0
for i in range(2,k+1):
    for j in range(2,k+1):
            if s-(i+j) in range(2,k+1):
                ans+=1
print(ans)
k,s = map(int,input().split())

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

for p in range(k+1):
    for q in range(min(k+1, s-p+1)):
        for r in range(min(k+1, s-p-q+1)):
            print(p, q, r)
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)
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+1 and 0<=S-i-j):
            count=count+1
print(count)
import math

k,s = map(int, input().split())
#n, x  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))

counter = 0
for i in range(k+1):
  for ii in range(k+1):
    for iii in range(k+1):
      if (s == i+ii+iii):
        counter = counter + 1
        print(i, ii, iii)
        
print(counter)
K,S = map(int,input().split())

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
    #print(num)
    if S-i % 2 == 0:
      z -= 1
      o += 1
    if min(S-i,i) == i:
      z -= 1
      o += 1 
if S % 3 == 0:
  t += 1
  o -= 1
#print(o,z,t)
print(z*6 + o*3 + t)
s,t=map(int,input().split())
ans=0
for i in range(s):
  for j in range(s):
    for k in range(s):
      if i+j+k==t+3:
        ans+=1
print(ans)
Max, Sum = map(int, input().split())

counter = 0
for i in range(Max+1):
  for j in range(Max+1):
    if Max -i -j >= 0:
      k = Max -i -j
    if i + j + k == Sum:
      counter += 1
 
print(counter)
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    if x+y>=s-k:
      count +=1
print(count)
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

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

print(c)
import itertools
k,s=map(int,input().split())

arr=[]
cnt=0

for x in range(k+1):
  for y in range(x,k+1):
    z=s-x-y
    if 0<=z<=k:
      print((x,y,z))
      if x==y==z:
        cnt+=1
        print('add 1')
      elif x==y or y==z or z==x:
        cnt+=3
        print('add 3')
      else:
        cnt+=6
        print('add 6')
print(cnt)
K,S=map(int,input().split())
ans=0

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

print(ans)
import itertools

K,S = map(int, input().split())
X = list(range(K+1))
Y = list(range(K+1))
Z = list(range(K+1))
count=0

for x,y,z in list(itertools.product(X, Y, Z)):
    if x+y+z == K:
        count+=1

print(count)
from itertools import combinations_with_replacement


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

ans = 0
for v in combinations_with_replacement(range(k + 1), 3):
    if sum(v) == s:
        leng = len(set(v))
        if leng == 1 or leng == 3:
            ans += 1
        else:
            ans += 3

print(ans)
import sys
input = sys.stdin.readline
K, S = map(int, input().split())
table = [0] * (2 * K + 1)
for x in range(K + 1):
  for y in range(K + 1):
    table[x + y] += 1
res = 0
#print(table)
for z in range(S - K, min(2 * K + 1, S + 1)): res += table[z]
print(res)
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  k,s = map(int,input().split())
  ans = 0
  for i in range(k):
    for j in range(k):
      z = s - i - j
      if 0 <= z <= k:
        ans += 1
  print(ans)
  
if __name__ == '__main__':
  main()
K, S = map(int, input().split())
ans = 0

#全て同じ
for x in range(K+1):
    if 3*x == S:
        ans += 1

#二つ同じ
for x in range(K+1):
    for y in range(x+1, K+1):
        if 2*x + y == S or x + 2*y == S:
            ans += 3

#全て違う
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:
                ans += 1

print(ans)
K, S = map(int, input().split())
c = 0
for x in range(K + 1):
    for y in range(x + 1):
        for z in range(y + 1):
            if x + y + z == S:
                c += 3
for x in range(K + 1):
    if 3 * x == S:
        c -= 2
print(c)
#coding: utf-8
K,S=map(int,input().split(" "))
answer=0
for X in range(K+1):
  for Y in range(K+1):
    print(X,Y)
    if S-(X+Y)<=K and S-(X+Y)>=0:
      answer+=1
print(answer)
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    tmp=s-i
    if tmp<=k:
        ans+=tmp+1
    elif 2*k<tmp:
        pass
    else:
        tmp1=2*k-tmp
        ans+=tmp1+1
    # print(tmp)
print(ans)
[K, S] = list(map(int, input().split()))
count = 0
total = 0
flag = False
for X in range(K, -1, -1):
  for Y in range(K, -1, -1):
    Z = S - X - Y
    print(X, Y, Z)
    if 0 <= Z and Z <= K:
      count +=1
    if K < Z:
      flag = True
  if flag:
    break
        
print(count)
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 0

for i in range(K+1):
    x = i
    for j in range(K+1-i):
        y = j
        for k in range(K+1-i-j):
            z = k
            if x+y+z == S:
                n += 1

print(n)
import sys
input = sys.stdin.readline
K,S=2500,5692

ans = []
 
for i in range(K+1):
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)

print(sum(ans))
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 z<=K:
            cnt += 1
print(cnt)
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num *3
    print(num)
k, s = map(int, input().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        if x + y <= k:
            cnt += 1
print(cnt)
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s:
            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 K >= S-x-y:
            ans += 1
            break

print(ans)
# 2017-01-07
import itertools

K,S = map(int, input().split())
X = list(range(K+1))
Y = list(range(K+1))
Z = list(range(K+1))
count=0

for x,y,z in list(itertools.product(X, Y, Z)):
    if x+y+z == S:
        print(x,y,z)
        count+=1

print(count)
K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S :
      ans+=1

print(ans)
k, s = 2, 2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z >= 0 and x+y+z == s:
            ans += 1
print(ans)
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 X + Y + Z == S:
        count += 1
print(count)
K,S=map(int,input().split())
ans=0

for i in range(K+1) :
    if S-i>2*K :
        continue
    if S-i<=K :
        ans+=S-i+1
    else :
        ans+=2*K+i-S+1

print(ans)
k,s = map(int,input().split())
start = k//3
ans = 0
for i in range(start,k+1):
    for j in range(start,k+1):
        for l in range(start,k+1):
            if i+j+l == s:
                ans += 1
print(ans)
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            x+y+z==s
            cnt+=1
print(cnt)
limit, sum_xyz = map(int, input().split())

pair = list()

for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        pair.append([x, y, z])
ans = len(pair)
def main():
    domain, num_sum = map(int, input().split())
    answer = 0
    for i in range(domain + 1):
        if num_sum < i or 2 * domain < (num_sum - i):
            continue
        else:
            if domain < num_sum - i - 1:
                answer += num_sum - i - 2 * domain + 1
            elif not i == num_sum:
                answer += domain + 1
    print(answer)


if __name__ == '__main__':
    main()
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)
    print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
K, S = map(int, input().split())
count = 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:
                count += 1
if count==1:
    print(count)
else:
    print(count*3)
K,S=map(int,input().split())
ans=1
#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
    if i+j>S :
      break

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

if S%3==0:
    x=int(S/3)
elif S%2==0:
    x=int(S/2)
else:
    x=int(S)

print("x=",x)
ans=0

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

print(ans)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
  for y in range(s-x+1):
    z = s - x - y
    if 0 <= z <= k:
      ans += 1
print(ans)
# -*- coding: utf-8 -*-
K, S = map(int, input().split())

n_int = 0

for z in range(min(K, S)+1):
    for y in range(min(K, S-z)+1):
        n_int += 1

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

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

print(ans)
k,s = map(int,input().split())
ans = 0
#
if s <= k:
    for x in range(s + 1):
        for y in range (s - x + 1):
            ans += 1
elif (s > k) and (s <= 2*k):
    for x in range(k + 1):
        for y in range(s - x + 1):
            ans += 1
else:
    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())
cnt=0
for x in range(s+1):
    for y in range(s+1):
        for z in range(s+1):
            if x+y+z==s:
                cnt+=1
print(cnt)
k, s = map(int, input().split())
count = 0
temp = s-2*k if (s-2*k)>0 else 0
for x in range(temp, k-1):
    for y in range(x+1, k):
        if (s-x-y)>y:
            count += 6
for x in range(temp, k+1):
    for z in range(temp, k+1):
        if x*2 + z == s:
            if x == z:
                count += 1
            else:
                count += 3
print(count)
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(k+1):
    if 0 <= s-i-k <= k:
      ans += 1
print(ans)
k, s = map(int, input().split())
count = 0
for a in range(k):
  for b in range(k):
    for c in range(k):
      if a + b + c == s:
        count += 1
      else:
        pass
print(count)
K,S = map(int,input().split())

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
    print(num)
    if S-i % 2 == 0:
      z -= 1
      o += 1
    if min(S-i,i) == i:
      z -= 1
      o += 1 
if S % 3 == 0:
  t += 1
  o -= 1
print(o,z,t)
print(z*6 + o*3 + t)
K, S = map(int, input().split())

cnt = 0

for i in range(K+1):
    for j in range(K+1):
        z = S - i - j
        if S == z:
            cnt += 1

print(cnt)
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(s-i+1):
    for l in range(s-i-j+1):
      ans += 1
print(ans)
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(min(K,S-x+1)):
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)
#from scipy.misc import comb

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

#a = comb(3*K, S, exact=True)
#print(a)

ans = 0
for i in range(x+1):
  for j in range(x-i+1):
    for k in range(x-i-j+1):
      if i+j+k==S:
        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 s-(x+y)<=k:
           ans+=1
print(ans)
k, s = map(int, input().split())
r = 0
for x in range(k + 1):
    for y in range(x, k + 1):
        z = s - x - y
        if 0 <= z <= k and z + x + y == s:
            r += 1
print(r)
import sys
input = sys.stdin.readline

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())

count=0

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

n = list(range(0,k + 1))

import itertools
ans = 0
for v in itertools.combinations_with_replacement(n, 3):
  if sum(list(v)) == s:
    if v[0] == v[1] == v[2]:
      ans += 1
    elif v[0] == v[1] or v[0] == v[2] or v[1] == v[2]:
      ans += 3
    else:
      ans += 3

print(ans)
(k, s) = list(map(int, input().split()))
count = 0
kmax = (s / 3) if s % 3 == 0 else (s / 3 + 1)
for x in range(k + 1):
    if s - x > kmax * 2:
        continue
    for y in range(k + 1):
        if s - x - y > kmax:
            continue
        for z in range(k + 1):
            if s == x + y + z:
                count += 1
print(count)
k, s=map(int, input().split())
ans=[]
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:
                ans.append((x, y, z))

print(6*len(ans))
x,y = list(map(int, input().split()))
count=0
for i in range(x):
    for j in range(x):
        for k in range(x):
            a=i+j+k
            if y==a:
                count+=1
print(count)
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
  for y in range(K+1):
    if S - x - y <= K:
        cnt += 1
print(cnt)
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
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 <= k and z<=k:
            ans += 1 
print(ans)
from itertools import combinations_with_replacement

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

ans = 0
for x, y, z in combinations_with_replacement(range(k+1), 3):
    if x + y + z == s:
       ans += 1

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

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

pat = 0
for x in range(k+1):
    for y in range(k+1):
            if s >= x + y :
                pat += 1
print(pat)
s,t=map(int,input().split())
ans=0
for i in range(0,s+1,1):
  for j in range(0,s+1,1):
    if not s<t-i-j:
      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):
        for k in range(0,K+1):
            if i+j+K == S:
                count +=1

print(count)
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for x in range(a+1):
    if sums-x <=2*a:
      for y in range(a+1):
        if sums-x-y<=a:
          ret+=1
  print(ret-mai)
K,S = map(int,input().split())
counter = 0
for i in range(K+1):
  for j in range(K+1):
    k = S - i - j
    if(k >= 0):
      counter += 1
print(counter)
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<=2500:
      ans+=1
print(ans)
import sys
input = sys.stdin.readline
K, S = map(int, input().split())
table = [0] * (2 * K + 1)
for x in range(K + 1):
  for y in range(K + 1):
    table[x + y] += 1
res = 0
#print(table)
for z in range(S - K, 2 * K + 1): res += table[z]
print(res)
k, s = list(map(int, input().split()))
count = 0

for p in range(k+1):
    for q in range(k-p+1):
        for r in range(k-p-q+1):
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)
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:
              ans+=1

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

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

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

ins = lambda: map(int,sys.stdin.readline().split(' '))

k,s = ins()

result = 0

for x in range(k+1):
    for y in range(k+1):
        if (s-x-y)<=k:
            result+=1
        
            
print(result)
K, S = map(int, input().split())
print((S+1)*(S/2 + 1) - max(0, S-K)*(max(0,S-K)+1)/2)
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())
K = K + 1
count = 0
for i in range(K):
    for j in range(K):
        z = S - i - j
        if z <= K and z >= 0:
            count += 1
print(count)
from math import factorial

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

print(ans)
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 <= K:
            ans += 1

print(ans)
k, s = map(int, input().split())
arr = [[x, y, s-x-y] for x in range(k+1) for y in range(k+1-x) if k >= s-x-y >= 0]
print(len(arr))
k, s = map(int, input().split())
count = 0
for x in range(k):
    for y in range(k):
        for z in range(k):
            if x + y + z == s:
                if x == y == z:
                    count += 1
                else:
                    count += 2

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

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))
  else:
    answer.append(s_z + 1)
    
print(sum(answer))
(k, s) = list(map(int, input().split()))
count = 0
kmax = int(s / 3) if s % 3 == 0 else int(s / 3) + 1
print(kmax)
for x in range(kmax + 1):
    for y in range(kmax + 1):
        for z in range(kmax + 1):
            if s == x + y + z:
                print(s, x, y, z)
                count += 1
print(count)
k,s = map(int ,input().split())
cou = 0
 
for i in range(k) :
  for j in range(k):
    for h in range(k):
      if i + j + h == s:
        cou += 1
print(cou)
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+1:
            count+=1
print(count)
k, s = [int(i) for i in input().split()]

count = 0
for x in range(k,-1,-1):
    a = s - x
    if a > 2*k:
        break

    for y in range(a//2, -1, -1):
        z = a - y
        if z == k:
            count += 1
        else:
            break

print(count)
k, s = 2,2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if z >= 0:
            	ans += 1
print(ans)
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 = c*3
        else:
            num = num*3
    print(num)
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:
      #print(i, j, (S - (i + j)))
      count += 1
print(count)
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
k,s=map(int,stdin.readline().split())
print(((k+2)*(k+1))//2)
k,s = map(int,input().split())
n = 3*k-s
ans = 0
if n == 0:
  ans = 1
elif n<0:
  None
else:
  for i in range(min(k,n),min(k-1,(n-1)//3),-1):
    t = min(k,n-i,i)
    for j in range(t,min(t-1,(n-i-1)//2),-1):
      k = n-i-j
      if i!= j and j != k:
        ans += 6
      elif i == j == k:
        ans += 1
      else:
        ans += 3
print(ans)
k, s = map(int, input().split())
cnt=0

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

print(cnt)
K, S = map(int, input().split())
print([S - x - y <= K for x in range(K+1) for y in range(K+1)].count(True))
K = 2
S = 2
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)
k, s = map(int, input().split())
ans = 0

for i in range(k):
    for j in range(k):
        for m in range(k):

            if i + j + m == s:
                ans += 1

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

ans = 0
for i in range(K+1):
    if 0<= S-i <= K:
        ans += (S-i)+1
    elif S-i <= 2*K:
        a = (S-i) -K
        ans += (K-a)+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())
n=sum( 0<=s-i-j<=k for i in range(k) for j in range(k))
print(n)
k, s = map(int, input().split())
cnt = 0
for x in range(k):
    for y in range(k):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
print(cnt)
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  for y in range(K + 1):
    if x > K:
      break
    for z in range(K + 1):
      if x + y > K:
        break
      if x + y + z == S:
        ans += 1
print(ans)
import itertools

s, k = map(int, input().split())
permutations_lis = list(itertools.product(range(k+1), repeat=3))
cnt = 0
for i in permutations_lis:
    if i[0] + i[1] + i[2] == s:
        cnt += 1
print(cnt)
K, S = map(int, input().split())

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed+1)
print(res)
k,s = map(int,input().split())
s = s + 1
count = 0
for x in range(k):
    for y in range(k):
        z = s - x - y
        if x + y + z == s:
            count += 1
            
print(count)
def main():
    K, S = map(int, input().split())

    ans = 0
    for x in range(K + 1):
        if x == S:
            ans += 1
            continue
        for y in range(K + 1):
            if x + y == S:
                ans += 1
                continue
            if S - x - y <= K:
                ans += S - x - y
    print(ans)


if __name__ == "__main__":
    main()
K, S = map(int, input().split())
a = 0
for x in range(K+1):
  for y in range(K+1):
    if S-x-y<=K :
      a+=1   
print(a)
k,s=map(int,input().split())
ret=0
k+=1
for i in range(k):
  for j in range(k):
    if 0<=(i+j)<=s:
      ret+=1
print(ret)
k, s = map(int, input().split())
i = 0
for x in range(0,k+1):
    for y in range(0,min(s-x,k)+1):
        if  2 <= s-x-y <= k:
            for z in range(0,s-x-y+1):
                if x+y+z == s : i += 1 
#        if s-x-y <= k & x+y <= s: i += 1 
#            if x+y+z == s: i += 1
print(i)
#from scipy.misc import comb

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

#a = comb(3*K, S, exact=True)
#print(a)

ans = 0
for i in range(x+1):
  for j in range(S-i+1):
    for k in range(S-i-j+1):
      if i+j+k==S:
        ans += 1
print(ans)