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

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


print(counter)

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

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 S == x + y + z:
                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()))
print((len([1 for i in range(K+1) for j in range(K+1) for k in range(K+1) if i+j+k==S])))


# Optimized solution
K,S=list(map(int,input().split())) 
print((len([True for x in range(K+1) for y in range(K+1) if (S-x-y>=0) and (S-x-y<=K)])))
# 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):
            sum = i + j + k
            if sum == 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 S - (i + j) < 0 or S-(i+j)>K:
            cnt = cnt
        else:
            cnt += 1

print(cnt)
# Original solution
k, s = input().split(" ")
count = 0

for x in range(int(k)+1):
  for y in range(int(k)+1):
    z = int(s) - x -y
    if z >= 0 and z <= int(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 z >= 0 and z <= k:
      count += 1

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

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

r = 0
for a in range(k + 1):
    if a > s:
        break
    for b in range(k + 1):
        if a + b > s:
            break
        for c in range(k + 1):
            if a + b + c == s:
                r += 1
                break
            if a + b + c > s:
                break
print(r)


# Optimized solution
k, s = [int(x) for x in input().split(' ')]
r = 0
for a in range(k + 1):
    if a > s:
        break
    for b in range(k + 1):
        if a + b > s:
            break
        elif s - (a + b) < k + 1:
            r += 1
print(r)
# Original solution
k, s = [int(x) for x in 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:
				if x==y and x==z:
					count+=1
				elif x==y or x==z or y==z:
					count+=3
				else:
					count+=6
print(count)

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

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

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

num = 0
for x in range(K + 1):
	rest = S - x
	if 0 <= rest and rest <= K:
		num += rest + 1
	elif K < rest and rest <=2*K:
		num += 2*K + 1 - rest
print(num)
# 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 i + j <= S and i + j >= S - K:
        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()))
ans = 0
i = list(range(k+1))

for x in i:
    for y in i:
        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):
    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 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 S - (X + Y) <= K and S - (X + Y) >= 0:
        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 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 = [int(i) for i in input().split()]

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

print(counter)

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

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

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

for x in range(k,-1,-1):
    if s-x > k*2:
        break
    if s < x:
        continue
    for y in range(k,-1,-1):
        if s-x-y > k:
            break
        if s < x+y:
            continue
        for z in range(k,-1,-1):
            if s-x-y-z > 0:
                break
            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,-1):
    if s-x > k*2:
        break
    if s < x:
        continue
    for y in range(k,-1,-1):
        if s-x-y > k:
            break
        if 0<= s-x-y <=k:
            ans +=1

print(ans)
# Original solution
# ABC 051 B Sum of Three Integers

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

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

print(res)

# Optimized solution
# ABC 051 B Sum of Three Integers

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

res = 0

for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <= k:
            res += 1
    
    
print(res)
# Original solution
import math
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
import math
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 K >= z:
            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):
        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 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)
# 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 z < 0:
            continue
        if z <= k:
            # print(x, y, z)
            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
import itertools

N = input().split()
N = [int(i) for i in N]
num = [i for i in range(N[0]+1)]

count = 0

#1
for i in range(N[0]+1):
    if(3*i == N[1]):
        count += 1

l2 = list(itertools.combinations(num, 2))
l3 = list(itertools.combinations(num, 3))
#print(num)
#print(l2)

#2
for i in range(len(l2)):
    if((l2[i][0] + 2*l2[i][1]) == N[1]):
        count += 1*3
    if((l2[i][0]*2 + l2[i][1]) == N[1]):
        count += 1*3

#3
for i in range(len(l3)):
    if((l3[i][0] + l3[i][1] + l3[i][2]) == N[1]):
        count += 1*6

print(count)


# Optimized solution
N = input().split()
N = [int(i) for i in N]
count = 0
for i in range(N[0]+1):
    for j in range(N[0]+1):
        k = N[1] - i - j
        if((k <= N[0])and(k>=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):
            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):
    if i>s:
        break
    for j in range(k+1):
        if i+j>s:
            break
        if i+j+k>=s:
            cnt += 1
print(cnt)
# Original solution
k, s = list(map(int, input().split()))
cnt = 0
for a in range(k+1):
    for b in range(k+1):
        for c in range(k+1):
            if a+b+c == s:
                cnt += 1
print(cnt)


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

# Optimized solution
k,s=list(map(int,input().split()))
l=list(range(k+1))
count=0
for i in l:
    for j in l:
        q=s-i-j
        if 0<=q<=k:
            count+=1
            
print(count)
# Original solution
# -*- coding: utf-8 -*-

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 z < 0 or z > K:
            continue
        if x + y + z == S:
            count += 1

print(count)


# 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
K,S=list(map(int,input().strip().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(x,y,z)
print(count)
            


# Optimized solution
"""
K,S=map(int,input().strip().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(x,y,z)
print(count)
            
"""

K,S=list(map(int,input().strip().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 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 s - k <= x + y <= s:
            count += 1
print(count)
# Original solution
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 Z in range(0,K+1):
            res += 1
print(res)

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

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

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

for i in z:
  s_z = S - i
  if K < s_z:
    for x in list(range(s_z - K,K+1)):
      y = s_z - x
      answer.append([x, y, z])

  else:
    for x in list(range(0,s_z+1)):
      y = s_z - x
      answer.append([x, y, z])

print((len(answer)))

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

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

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif 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)))
# Original solution
K,S=list(map(int,input().split()))

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

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif 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)))

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

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

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print((sum(ans)))
# Original solution
K,S=list(map(int,input().split()))
z = list(range(0,K+1))
ans = []
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)
print((sum(ans)))

# Optimized solution
import sys
input = sys.stdin.readline

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

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

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print((sum(ans)))
# Original solution
import sys
input = sys.stdin.readline
 
K,S=list(map(int,input().split()))

if S < K:
  K = S
 
z = list(range(K+1))
ans = []
 
for i in z:
  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)))

# Optimized solution
import sys
input = sys.stdin.readline
 
K,S=list(map(int,input().split()))
ans = []

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

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

# Optimized solution
i = list(map(int, input().split()))
k = i[0]
s = i[1]
#print("k=",k,"s=",s)
ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = s-x-y
    #print("x=",x,"y=",y,"z=",z)
    if k >= z and z >=0:
        #print("clear!")
        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) :
        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
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 z >= 0 and z <= k :
            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()))
res = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        res += 1
print(res)

# Optimized solution
k, s = list(map(int, input().split()))
res = 0
for x in range(k+1):
  if 3 * x == s:
    res += 1
for x in range(k+1):
  for y in range(k+1):
    if x == y:
      continue
    if 2 * x + y == s:
      res += 3
for x in range(k+1):
  for y in range(x+1, k+1):
    d = s - x - y
    if d > y and d <= k:
      res += 6

print(res)
# 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
            if i+j+k > S: break
        if i+j > S: break
    if i > S: break

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
        if S-i-j < 0: break
    if i > S: break

print(ans)
# Original solution
a=list(map(int,input().split()))
ans=0
for i in range(a[0]+1):
    for j in range(a[0]+1):
        for k in range(a[0]+1):
            if i+j+k==a[1]:
                ans+=1
print((str(ans)))

# Optimized solution
a=list(map(int,input().split()))
ans=0
for i in range(a[0]+1):
    for j in range(a[0]+1):
        if a[1]-i-j <= a[0] and a[1]-i-j >= 0:
            ans+=1
print((str(ans)))
# Original solution
a=list(map(int,input().split()))
ans=0
for i in range(a[0]+1):
    for j in range(a[0]+1):
        if a[1]-i-j < a[0]+1 and a[1]-i-j > -1:
            ans+=1
print((str(ans)))

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

count = 0
for x in range(k+1):
    if s - x > 2 * k:
        continue
    for y in range(k+1):
        if s - (x+y) > k:
            continue
        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):
    if s - x > 2 * k:
        continue
    for y in range(k+1):
        if s - (x+y) > k or s -(x+y) < 0:
            continue
        count += 1

print(count)
# Original solution

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

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

print(number_of_combinations)

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