CodeEff/ECCO huggingface dataset:
# Original solution
K, S = [int(n) for n in 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
            elif (X+Y+Z) > S:
                break
print(ans)


# Optimized solution
K, S = [int(n) for n in input().split(' ')]

ans = 0

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


# Optimized solution
K,S=list(map(int,input().split()))
num=0
for i in range(K+1):
    for j in range(K+1):
        k=S-i-j
        if 0<=k<=K:
            num+=1
print(num)
# Original solution
k, s  = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(i, k + 1):
        for l in range(j, k + 1):
            if i + j + l == s:
                if i == j == l:
                    ans += 1
                elif i == j or j == l:
                    ans += 3
                elif i != j != l:
                    ans += 6
print(ans)

# Optimized solution
k, s  = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(i, k + 1):
        if j <= s - i - j <= k:
            l = s - i - j
            if i == j == l:
                ans += 1
            elif i == j or j == l:
                ans += 3
            elif i != j != l:
                ans += 6
print(ans)
# 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 0 <= z <= k:
            ans += 1

print(ans)
# Original solution
ks= list(map(int, input().split())) 
 
count = 0
 
x = 0
y = 0
z = 0
 
for targetX in range(ks[0]+1):
    
    for targetY in range(ks[0]+1):
        
        z = ks[1] - (targetX + targetY)
        
        if 0 <= z and z <= ks[0]:
            count += 1
            
    
        targetY +=1
        
    targetX +=1
        
 
print(count)

# Optimized solution
ks= list(map(int, input().split())) 
 
count = 0
 
x = 0
y = 0
z = 0
 
for targetX in range(ks[0]+1):
    
    
    if targetX <= ks[0] and ks[1]-(targetX+ks[0]+ks[0]) <= 0:
    
        for targetY in range(ks[0]+1):
            
            z = ks[1] - (targetX + targetY)
            
            if 0 <= z and z <= ks[0]:
                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):
        k = S - i - j
        if 0<= k <= K:
            cnt += 1
                
print(cnt)
# Original solution
K,S = input().strip().split()
K,S = int(K),int(S)

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 = input().strip().split()
K,S = int(K),int(S)

count = 0

for x in range(S+1):
  for y in range(S+1-x):
    z = S - x- y
    #print( x,y,z)
    if x <= K and y <= K and z <= K:
      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):
        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()))

counter = 0

for x in range(0,K+1):
	for y in range(0,K+1):
		for z in range(0,K+1):
			if(S == x+y+z):
				counter += 1

print(counter)

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

counter = 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)):
			counter += 1 

print(counter)
# Original solution
k,s = list(map(int,input().split()))

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

count = (K + 1) ** 3
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):
        if 0 <= S - (x + y) <= 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 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 s-k <= i+j <= s:
        count += 1
print(count)
# Original solution
K_S = input().split(" ")
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)
    

# Optimized solution
K_S = input().split()
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)
# 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):
        z = S - x - y
        if 0 <= z and z<= K:
            c += 1
print(c)
# 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):
        k = S - i - j
        if k >= 0 and k <=K:
                count +=1
print(count)
# Original solution
import sys
input=sys.stdin.readline
K,S=list(map(int,input().split()));c=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:
        break
      if x+y+z == S:
        c+=1
print(c)

# Optimized solution
import sys
input=sys.stdin.readline
K,S=list(map(int,input().split()));c=0
for x in range(K+1):
  for y in range(K+1):
    z = S-x-y
    if 0<=z<=K:
      c+=1
print(c)
# Original solution
K,S=list(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)

# Optimized solution
K,S=list(map(int, input().split()))
print((len([1 for x in range(K+1) for y in range(K+1) if 0<=S-x-y<=K])))
# 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
      else:
        continue
        
print(count)

# Optimized solution
K,S=list(map(int,input().split()))
count=0
for X in range(K,-1,-1):
  if S-X>2*K:
    break    
  for Y in range(K,-1,-1):
    if 0<=S-(X+Y)<=K:
       count+=1
    elif 0>S-(X+Y):
       continue
    else:    
       break
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:
                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()))
res = 0

for x in range(K + 1):
    tmp = S
    if tmp - x == 0:
        res += 1
        continue
    for y in range(K + 1):
        if tmp - x - y == 0:
            res += 1
            continue
        for z in range(K + 1):
            if tmp - x - y - z == 0:
                res += 1
                continue
print(res)


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

for x in range(K + 1):
    for y in range(K + 1):
        if S - x - y >= 0 and S - x - y <= K:
            res += 1
print(res)
# 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):
        x=i
        y=j
        z=s-i-j
        if 0<=z<=k:
            ans+=1
        else:
            ans+=0



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):
        z=s-i-j
        if k>=z>=0:
            ans+=1
            #print(i,j,z)
print(ans)
# Original solution
K, S = [int(v) for v in input().split()]

cnt = 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:
                break
            if x + y + z == S:
                cnt += 1
print(cnt)


# Optimized solution
K, S = [int(v) for v in input().split()]

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        if S - (x + y) >= 0 and S - (x + y) <= K:
            cnt += 1
print(cnt)
# Original solution
k, s = list(map(int, input().split(' ')))
cnt_pattern = 0
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      if s == a + b + c:
        cnt_pattern += 1
        if s < a + b + c:
          break
print(cnt_pattern)

# Optimized solution
k, s = list(map(int, input().split(' ')))
cnt_pattern = 0
for a in range(k + 1):
  for b in range(k + 1):
    if 0 <= s - a - b <= k:
      cnt_pattern += 1
print(cnt_pattern)
# 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
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
K,S=list(map(int,input().split()))
cnt=0

for i in range(K+1):
	x=i
	for j in range(K+1):
		y=j
		if i+j<=S and i+j>=S-K:
			cnt+=1

print(cnt)

# Optimized solution
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
k,s=list(map(int,input().split()))
cnt=0

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

l = []

for i in range(K + 1):
    l.append(i)

count = 0

for i in l:
    x = i
    for j in l:
        y = j
        for k in l:
            z = k
            if (x + y + z) == S:
                count += 1

print(count)


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

l = []

for i in range(K + 1):
    l.append(i)

count = 0

for i in l:
    for j in l:
        z = S - i - j
        if 0 <= z and z <= K:
            count += 1

print(count)
# Original solution
k, s = list(map(int, input().split()))

cnt = 0
for i in range(k+1):
  for m in range(k+1):
    for n in range(k+1):
      if i + m + n == 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
k_num, s_num = list(map(int, input().split()))

cnt = 0
for x in range(k_num+1):
    for y in range(k_num+1):
        for z in range(k_num+1):
            if x + y + z == s_num:
                cnt += 1

print(cnt)

# Optimized solution
k_num, s_num = list(map(int, input().split()))

cnt = 0
for x in range(k_num+1):
    l = s_num - x
    for y in range(k_num+1):
        z = l - y
        if 0 <= z <= k_num:
            cnt += 1

print(cnt)
# Original solution
import queue

def count(S, K):
    c = 0
    q = queue.Queue()
    q.put((S, 0))
    s = []
    while(q.empty() == False):
        x, y = q.get()
        if x < 0:
            break
        if x <= K and y <= K and S-x-y <= K and (x, y) not in s:
            s.append((x, y))
            c += 1
        q.put((x-1, y+1))
        q.put((x-1, y))
    return c

if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    K = inp[0]
    S = inp[1]
    print((count(S, K)))

# Optimized solution
if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    K = inp[0]
    S = inp[1]
    c = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if z >= 0 and z <= K:
                c += 1
    print(c)
# Original solution
K, S = list(map(int, input().split()))
count = 0

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

print(count)


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

for x in range(0, K+1):
    for y in range(0, K+1):
        z = S-x-y
        if 0 <= z <= K:
            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):
        for l in range(k+1):
            if i+j+l == 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):
        dum = (s - (i + j))
        if dum < 0:
            continue
        if dum <= k:
            ans += 1
print(ans)
# Original solution
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
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(S-x-y+1):
          if z > K or x + y + z != S:
            continue
          count += 1
            
# 出力
print(count)


# Optimized solution
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
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 and 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(k+1):
        if s-k<=i+j<=s:
            count+=1
print(count)


# Optimized solution
k,s=list(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)
# Original solution
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

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 <=K and z>=0:
            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 0<=z and z<=k:
            cnt+=1

print(cnt)
# Original solution
li = list(map(int,input().split()))
k = li[0]
s = li[1]
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
# ABC 051 B - Sum of Three Integers　
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
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):
        k = S-i-j
        if -1 < k <=K:
            cnt+=1
print(cnt)

# Optimized solution
# B - Sum of Three Integers
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 K>=z:
            cnt+=1
print(cnt)
# Original solution
k,s = list(map(int,input().split()))
from itertools import product
ans = 0
for x,y,z in product(list(range(k+1)), repeat=3):
    #print(x,y,z)
    if x+y+z == s:
        ans += 1
print(ans)

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

'''from itertools import product
for x,y,z in product(range(k+1), repeat=3):
    #print(x,y,z)
    if x+y+z == s:
        ans += 1'''
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <= k:
            ans +=1
print(ans)
# Original solution
def main():
    K, S = list(map(int, input().split()))
    count=0


    if(S<=3725):
        for x in range(0, K+1):
            for y in range(0, K+1):
                for z in range(0, K+1):
                    if(x+y+z==S):
                        count+=1
    else:
        for x in reversed(list(range(0, K+1))):
            for y in reversed(list(range(0, K+1))):
                for z in reversed(list(range(0, K+1))):
                    if(x+y+z==S):
                        count+=1
    print(count)

main()

# Optimized solution
def main():
    K, S = list(map(int, input().split()))
    count=0

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

    print(count)

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

# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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 x + y + z == s and k >= z >= 0:
                res += 1

    print(res)


if __name__ == '__main__':
    resolve()
# Original solution
K, S = list(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:
                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):
    if S-x<=2*K and S-x>=0:
        for y in range(K+1):
            if S-x-y<=K and S-x-y>=0:
                count += 1
#                 for z in range(K+1):
#                     if x+y+z==S:
#                         count += 1
print(count)
# Original solution
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

count = 0
for X, Y, Z in itertools.product(list(range(0, K+1)), list(range(0, K+1)), list(range(0, K+1))):
    if (X + Y + Z) == S:
        count+=1
print(count)


# Optimized solution
import itertools

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

if not ((2 <= K and K <= 2500) or (0 <= S and S <= 3*K)):
    exit()

count = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        if 0 <= (S - X - Y) and (S - X - Y) <= 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
            elif x + y + z > s:
                break
        if x + y > s:
            break
    if x > s:
        break
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 and z <= k:
            count += 1
print(count)
# Original solution
from itertools import chain
# import numpy as np
# N = int(input())
# L,N = map(int,input().split())
# X = [list(map(int,input().split())) for x in range(N)]
K,S = list(map(int,input().split()))
patterns = 0

arr = [[[x+y+z for z in range(min(S-x-y+1,K+1))] for y in range(min(S-x+1,K+1))] for x in range(K+1)]
farr = list(chain.from_iterable(arr))
farr = list(chain.from_iterable(farr))
# print(farr)
print((farr.count(S)))
# print(patterns)

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

# # arr = [[x+y for y in range(min(S-x+1,K+1))] for x in range(K+1)]
# farr = list(chain.from_iterable(arr))
# for z in farr:
#     temp_z = S - z
#     if temp_z <= K and temp_z >=0:
#         patterns += 1
# print(farr)
# print(farr.count(S))

for x in range(K+1):
    for y in range(max(0,S-K-x), min(K+1,S-x+1)):
        patterns += 1
print(patterns)
# 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):
        if 0 <= s-x-y <=k:
            cnt+=1
print(cnt)
# Original solution
K,S=list(map(int,input().split()))
num=0
for X in range(S+1):
    if X>K:
        break
    for Y in range(S+1):
        Z=S-X-Y
        if Y<=K and K>=Z>=0:
            num+=1
print(num)

# Optimized solution
K,S=list(map(int,input().split()))
#K=5
#S=15
num=0
for X in range(K+1):
    if X>S:
        break
    for Y in range(K+1):
        Z=S-Y-X
        if 0<=Z<=K:
            
            num+=1
print(num)
# Original solution
"""AtCoder"""

K, N = 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  == N:
        ans += 1

print(ans)


# Optimized solution
"""AtCoder"""

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

ans = 0

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



print(ans)
# Original solution
K,S=list(map(int,input().split()))
ans=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    for Z in range(0,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(0,K+1):
  for Y in range(0,K+1):
    Z=S-X-Y
    if 0<=Z and Z<=K:
      ans+=1
print(ans)
# Original solution
from itertools import product

K,S=list(map(int,input().split()))
li_=list(product(list(range(K+1)),repeat=3))
ans=0
for x in li_:
  if sum(x)==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):
    Z=S-X-Y
    if 0<=Z<=K:
      ans+=1
print(ans)
# 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):
        z = s - x - y
        if 0 <= z <= k:
            ans += 1

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

print(count)