CodeEff/ECCO huggingface dataset:
# Original solution
k, s = list(map(int, input().split()))

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

print(ans)

# Optimized solution
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 <= k and z >= 0:
            #print(x, y, z)
            ans += 1

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


# Optimized solution
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 k >= z and 0 <= z:
            count += 1

print(count)
# Original solution
k,s=list(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)


# Optimized solution
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)
# Original solution
k, s = list(map(int, input().split()))
cnt = 0
lst = []

for i in range(k+1):
    for j in range(k+1):
        lst.append(i+j)

for i in range(len(lst)):
    for j in range(k+1):
        if lst[i]==s-j:
            cnt += 1

print(cnt)

# Optimized solution
k, s = list(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)
# Original solution
K,S=list(map(int,input().split()))
cnt=0
K+=1
for i in range(K):
  for j in range(K):
    for k in range(K):
      if i+j+k==S:
        cnt+=1
print(cnt)

# Optimized solution
K,S=list(map(int,input().split()))
cnt=0

for i in range(K+1):
  for j in range(K+1):
    k=S-(i+j)
    if (k>=0) and (k<=K):
      cnt+=1
print(cnt)
# Original solution
K,S=list(map(int,input().split()))
ans=0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i+j+k==S:
        ans+=1
print(ans)

# Optimized solution
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)
# Original solution
k, s = list(map(int, input().split()))
count = 0
k += 1
for x in range(k):
    for y in range(k):
        for z in range(k):
            if x + y + z == s:
                count += 1

print(count)


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

print(count)
# Original solution
K,S = list(map(int,(input().split())))

res = [(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(res)))

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

res = [(x) for x in range(K+1)
for y in range(K+1)
if x+y <= S and x+y >= S-K]

print((len(res)))
# Original solution
K, S = list(map(int, input().split()))

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

print(ways)

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

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

print(ways)
# Original solution
k,s=list(map(int,input().split()))
c=0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if(i+l+j==s):
                c+=1
print(c)


# Optimized solution
k,s=list(map(int,input().split()))
c=0
for i in range(k+1):
    for j in range(k+1):
        d=s-i-j
        if(d>=0 and d<=k):
            c+=1
print(c)
# Original solution
K, S = list(map(int, input().split()))
ans = 0

for x in range(K+1):
    for y in range(x+1):
        for z in range(y+1):
            if x+y+z == S:
                
                if x==y==z:
                    ans += 1
                elif x==y or y==z or x==z:
                    ans += 3
                else:
                    ans += 6
print(ans)

# Optimized solution
k,s=list(map(int,input().split()))
c=0
for i in range(k+1):
    for j in range(k+1):
        if s>=i+j and s-(i+j)<=k:
            c+=1
print(c)
# Original solution
k,s=list(map(int,input().split()))
c=0
for i in range(k+1):
    for j in range(k+1):
        if s>=i+j and s-(i+j)<=k:
            c+=1
print(c)

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

ans = 0

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

print(ans)
# Original solution
K, S = list(map(int, input().split()))
ans = 0
for a in range(K+1):
    for b in range(K+1):
        for c in range(K+1):
            if a + b + c == S:
                ans += 1
print(ans)

# Optimized solution
K, S = list(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)
# Original solution
K,S=list(map(int,input().split()))

c=0

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

print(c)
                


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

c=0

for i in range(K+1):
    for j in range(K+1):
        if i+j+K>=S and i+j<=S:
            c+=1

print(c)
# Original solution
K,S = list(map(int,input().split(" ")))
     
s = 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):
      if x +y +z ==S:
        s +=1
      if x + y + z >S:
        break
     
print(s)

# Optimized solution
K,S = list(map(int,input().split(" ")))
             
s = 0
             
for x in range(K+1):
  for y in range(min(K+1,S-x+1)):
    if 0<=S-x - y <= K:
      s+=1
                     
print(s)
# Original solution
k,s = list(map(int,input().split()))
cnt=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if (x+y+z==s):
                cnt=cnt+1
print(cnt)

# Optimized solution
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 (z>=0)&(z<=k):
            cnt=cnt+1
print(cnt)
# Original solution
k, s = list(map(int,input().split()))
cnt=0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            total = i+j+k
            if total==s:
                cnt +=1
print(cnt)

# Optimized solution
k, s = list(map(int,input().split()))
cnt=0
for i in range(k+1):
    for j in range(k+1):
        z=s-i-j
        if z>=0 and z<=k:
            cnt +=1
print(cnt)
# Original solution
K, S = list(map(int, input().split()))

Xs = [i for i in range(K+1)]
Ys = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        if 0<= S - x - y <= K:
            count += 1
print(count)

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

Xs = [i for i in range(K+1)]

count = 0
for x in Xs:
    yz = S - x
    if 0 <= yz  <= K*2:
        count += K+1-abs(K-yz)
    
print(count)
# Original solution
ans=0
K,S=list(map(int,input().split()))
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z==S:
        ans+=1
print(ans)

# Optimized solution
ans=0
K,S=list(map(int,input().split()))
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-x-y and S-x-y<=K:
      ans+=1
print(ans)
# Original solution
ans=0
K,S=list(map(int,input().split()))
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-x-y and S-x-y<=K:
      ans+=1
print(ans)

# Optimized solution
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  K,S=list(map(int,pin().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)
  return 
main()
# Original solution
k, s = list(map(int, input().split()))
c = 0

for x in range(k + 1):
  for y in range(k + 1):
    for z in range(k + 1):
      if x + y + z == s:
        c += 1
print(c)


# Optimized solution
k, s = list(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)
# Original solution

from collections import Counter
from collections import defaultdict
from functools import lru_cache
import itertools
import random
import cProfile
import copy

N,M = list(map(int,input().split()))

X = [i for i in range(N+1)]

count = 0
for i in itertools.product(X,X,X):
	if sum(i) == M:
		count += 1
print(count)

# Optimized solution
import itertools

N,M = list(map(int,input().split()))
X = [i for i in range(N+1)]

count = 0
for x,y in itertools.product(X,X):
	if 0 <= M - x - y <= N:
		count += 1

print(count)
# Original solution
K, S = list(map(int, input().split()))

ans = 0

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

print(ans)

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

result = 0

for x in (list(range(K+1))):
    for y in (list(range(K+1))):
        if 0 <= S - x - y <=K:
            result +=1
print(result)
# Original solution
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
elif 3*a == b:
  print((1))
elif 3*a > b:
  for i in range(a+1):
    if i > b:
      break
    elif i == b:
      ans += 1
      continue
    elif i < b:
      if i+2*a < b:
        break
      elif i+2*a == b:
        ans += 1
        continue
      elif i+2*a > b:
        for j in range(a+1):
          if i+j > b:
            break
          elif i+j == b:
            ans += 1
            continue
          elif i+j < b:
            if i+j+a < b:
              break
            elif i+j+a == b:
              ans += 1
              continue
            elif i+j+a > b:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

# Optimized solution
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)
# Original solution
K,N = list(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)


# Optimized solution
K,S = list(map(int,input().split()))
count = 0
for i in range (K+1):
	for j in range (K+1):
		k=(S-i-j)
		if k<=K and k>=0:
			count += 1
			#print(i,j,k)
			
print(count)
# Original solution
K,S = list(map(int,input().split()))
count = 0
for i in range (K+1):
	for j in range (K+1):
		k=(S-i-j)
		if k<=K and k>=0:
			count += 1
			#print(i,j,k)
			
print(count)

# Optimized solution
K,N=list(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)
# Original solution
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 and S - i - j <= K:
            count += 1

print(count)

# Optimized solution
K, S = list(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)
# Original solution
k,s = list(map(int,input().split()))

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

print(cnt)


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

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

print(cnt)
# Original solution
K,S = list(map(int, input().split()))

count = 0

for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X+Y+Z == S:
        count += 1
  
print(count)

# Optimized solution
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 0<=Z and Z<=K:
      count += 1
  
print(count)
# Original solution
import itertools

K, S = list(map(int, input().split()))
count = 0
for v in itertools.combinations(list(range(S + 2)), 2):
    x = v[0]
    y = v[1] - v[0] - 1
    if max(x, y, S - x - y) <= K:
        count += 1
print(count)

# Optimized solution
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 0 <= z <= K:
            count += 1
print(count)
# Original solution
K,S = list(map(int,input().split()))

count = 0
for X in range(K + 1):
  for Y in range(K + 1):
    for Z in range(K + 1):
      if X + Y + Z == S:
        count += 1

print(count)

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

result = 0
for X in range(K + 1):
  YZ = S - X
  if 0 <= YZ <= K:
    result += YZ + 1
  elif K < YZ <= 2 * K:
    result += 2 * K + 1 - YZ
  
print(result)
# Original solution
a, b = list(map(int, input().split()))
c = 0
for i in range(a+1):
    for j in range(a+1):
        d = b - i - j
        if 0 <= d <= a:
            c += 1
print(c)


# Optimized solution
a, b = list(map(int, input().split()))
c = 0
for i in range(a+1):
    for j in range(a+1):
        if 0 <= b - i - j <= a:
            c += 1
print(c)
# Original solution
k,s=list(map(int,input().split()))
x=0
m=min(s+1,k+1)
for a in range(m):
  for b in range(m):
    if a+b>s:
      break
    for c in range(m):
      if a+b+c==s:
        x+=1
        break
print(x)

# Optimized solution
k,s=list(map(int,input().split()))
x=0
m=min(s+1,k+1)
for a in range(m):
  for b in range(m):
    if a+b>s or a+b<s-k:
      continue
    x+=1
print(x)
# Original solution
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 (0 <= z) and z <= K:
            ANS += 1

print(ANS)

# Optimized solution
K, S = (int(x) for x in input().split())
ans = 0

for X in range(0, K+1):
    for Y in range(0, K+1):
        Z = S - (X + Y)
        if 0 <= Z <= K:
            ans += 1

print(ans)
# Original solution
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)


# Optimized solution
def solve():
    K, S = [int(x) for x in input().split()]
    res = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 <= z <= K:
                res += 1
    return res

if __name__ == '__main__':
    print((solve()))
# Original solution
k, s = list(map(int, input().split()))

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

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

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

# Optimized solution
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:
            break
        if z <= k:
            count += 1

print(count)
# Original solution
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:
            break
        if z <= k:
            count += 1

print(count)

# Optimized solution
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 0 <= z <= k:
            count += 1

print(count)
# Original solution
K,S=list(map(int,input().split()))

count=0

for i in range(K+1):
    for j in range(i+1):
        for k in range(j+1):
            if i+j+k==S:
                #print(i,j,k)
                if i==j and j==k:
                    count+=1
                elif i==j or j==k or i==k:
                    count+=3
                else:
                    count+=6
print(count)

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

count=0

for x in range(K+1):
    for y in range(x+1):
        z=S-x-y
        if z<0 or z>y:
            pass
        else:
            #print(x,y,z)
            if x==y==z:
                count+=1
            elif x==y or x==z or y==z:
                count+=3
            else:
                count+=6
        
print(count)
# Original solution
#ABC51-B

K,S=list(map(int,input().split()))
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    #print(L)
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if sum==S: #X＝Sの場合
            count+=1
            #print(str(i)+" "+str(j))
            break
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)            

# Optimized solution
#ABC51-B

K,S=list(map(int,input().split()))
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    #print(L)
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)
# Original solution
#ABC51-B

K,S=list(map(int,input().split()))
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    #print(L)
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)          

# Optimized solution
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)
# Original solution
ks = list(map(int, input().split()))
k = min(ks)
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if ks[1] == x + y + z:
                ans += 1
            else:
                pass

print(ans)

# Optimized solution
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
        else:
            pass
        

print(ans)
# Original solution
K, S = list(map(int, input().split()))
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                cnt += 1
print(cnt)

# Optimized solution
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 z >= 0 and z <= K:
            cnt += 1
print(cnt)
# Original solution
ans = 0
k,s = list(map(int,input().split()))
for x in range(k+1):
	for y in range(k+1):
		z = s - x - y
		if 0 <= z and z <= k:
			ans += 1
print(ans)

# Optimized solution
k,s=list(map(int,input().split()))
print((sum([max(0,min(k,s-i)-max(0,s-i-k)+1) for i in range(k+1)])))
# Original solution
K,S = list(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)


# Optimized solution
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)
# Original solution
k, s = list(map(int, input().split()))

count = 0

for i in range(k + 1):
  for j in range(k + 1):
    for l in range(k + 1):
      if i + j + l > s:
        break

      if i + j + l == s:
        count+= 1

print(count)


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

count = 0

for i in range(k + 1):
  for j in range(k + 1):
    if i + j > s:
      break

    if s - (i + j) > k:
      continue

    count+=1

print(count)
# Original solution
K, S = list(map(int, input().split()))

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

print(cnt)

# Optimized solution
K, S = list(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)
# Original solution
# vim: fileencoding=utf-8


def main():
    k, s = list(map(int, input().split()))
    c = 0
    for i in range(k + 1):
        for j in range(k + 1):
            for l in range(k + 1):
                if i + j + l == s:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()


# Optimized solution
# vim: fileencoding=utf-8


def main():
    k, s = list(map(int, input().split()))
    c = 0
    for i in range(k + 1):
        for j in range(k + 1):
            z = s - i - j
            if z >= 0 and z <= k:
                c += 1
    print(c)


if __name__ == "__main__":
    main()
# Original solution
K,S = list(map(int,input().split()))
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        for _ in range(0,K+1):
            if i+j+_ == S:
                ans += 1
print(ans)

# Optimized solution
K,S = list(map(int,input().split()))
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        z = S-i-j
        if 0<=z<=K:
            ans += 1
print(ans)
# Original solution
K,S = list(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)


# Optimized solution
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)
# Original solution
k,s = list(map(int, input().split()))
ans = 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):
            if x+y+z==s:
                ans += 1
                break
print(ans)

# Optimized solution
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
    if x>s:
        break
    for y in range(k+1):
        if x+y<=s and s-(x+y)<=k:
            ans += 1
        if x+y>s:
            break
print(ans)
# Original solution
k, s = [int(i) for i in input().split()]

count = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                count += 1
print(count)

# Optimized solution
k, s = [int(i) for i in input().split()]

count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            # print("{} {} {}".format(x, y, z))
            count += 1
print(count)
# Original solution

K, S = list(map(int, input().split()))
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        ij = i + j
        if ij > S:
            break
        for k in range(K+1):
            if (ij + k == S):
                cnt += 1
print(cnt)



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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        ij = i + j
        if ij > S:
            break
        if (S - ij <= K):
            cnt += 1
print(cnt)
# Original solution
k,s = list(map(int,input().split()))
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1
print(ans)

# Optimized solution
k,s = list(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)