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

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()))
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S - x - y >= 0 and S - x - y <= 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 z >= 0 and z <= K:
            ans += 1
print(ans)
# Original solution
import itertools
k,s = list(map(int,input().split()))
ans = 0
x = [i for i in range(k + 1)]
y = [i for i in range(k + 1)]
z = [i for i in range(k + 1)]
arr = list(itertools.product(x,y,z))
for i in arr:
    if sum(i) == 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):
        for k in range(k + 1):
            if i + j + k == s:
                ans += 1
print(ans)
# Original solution
k,s=(int(x) for x in input().split())
ans=0
for i in range(k+1):
  for ii in range(k+1):
    for iii in range(k+1):
      if i+ii+iii==s:
        ans+=1
print(ans)

# Optimized solution
k,s=(int(x) for x in input().split())
ans=0
for i in range(k+1):
  for ii in range(k+1):
    if 0<=s-i-ii<=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:
        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):
  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(' ')))
r = 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:
                r += 1
print(r)

# Optimized solution
k, s = list(map(int, input().split(' ')))
r = 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:
            r += 1
print(r)
# Original solution
K, S = list(map(int,input().split()))
import itertools

ar = itertools.product(list(range(K+1)), repeat=3)

ans = 0
for a,b,c in ar:
  if a+b+c == S: ans += 1

print(ans)

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

ar = itertools.product(list(range(K+1)), repeat=2)

ans = 0
for a,b in ar:
  if S - a-b <= K and a+b <= S: ans += 1

print(ans)
# 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):
            count+=S==X+Y+Z

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):
        count+=X+Y<=S<=X+Y+K

print(count)
# Original solution
K, S = list(map(int, input().split()))
l = [i for i in range(K+1)]
cnt = 0
for i in l:
    if i > S:
        break
    elif i == S:
        cnt += 1
        break
    elif i < S:
        for j in l:
            if i+j > S:
                break
            elif i+j == S:
                cnt += 1
                break
            elif i+j < S:
                if K >= S-i-j:
                    cnt += 1
                
print(cnt)

# Optimized solution
K, S = list(map(int, input().split()))
l = [i for i in range(K+1)]
cnt = 0
for i in l:
    if i > S:
        break
    elif i == S:
        cnt += 1
        break
    elif i < S:
        tmp1 = S-i
        if K-tmp1 >= 0:
            cnt += tmp1 + 1
        else:
            tmp2 = 2*K + 1 - tmp1
            if tmp2 > 0:
                cnt += tmp2
                
print(cnt)
# Original solution
n, s = list(map(int, input().split()))
ans = 0
for x in range(n+1):
  for y in range(n+1):
    for z in range(n+1):
      if x + y + z == s:
        ans += 1
print(ans)

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

# Optimized solution
def main():
    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)
main()
# Original solution
K,S= input().split()
intK = int(K)
intS = int(S)
sum = 0
for X in range(intK+1):
    for Y in range(intK+1):
        Z = intS - (X+Y)
        if (Z < 0) or Z > intK:
            continue
        if Z >= 0 and (X+Y+Z) == intS:
            sum += 1
print(sum)

# Optimized solution
K,S= input().split()
intK = int(K)
intS = int(S)
sum = 0
for X in range(intK+1):
    for Y in range(intK+1):
        Z = intS - (X+Y)
        if (Z < 0) or Z > intK:
            continue
        sum += 1
print(sum)
# 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:
                                                #print('1','x',x,'y',y,'z',z)
                                                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<=k:
                                    ans+=1
                                                
print(ans)
# Original solution
k,s=list(map(int,input().split()))

c=0

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

# Optimized solution
k,s=list(map(int,input().split()))
 
c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1):
    if s<x+y:
      break
    elif s>x+y+k:
      continue
    else:
      c+=1
print(c)
# 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):
            s = x + y + z
            if s == S:
                count = count + 1    
print((str(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()))
c = 0
for x in range(K + 1):
    if x > S:
        continue
    for y in range(S - x + 1):
        if y > K:
            break
        z = S - x - y
        if 0 <= z <= K:
            c += 1
print(c)

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


# Optimized solution
k,s=list(map(int,input().split()))
print((len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k])))
# Original solution
k,s=list(map(int,input().split()))

l=[]

for i in range(max(0,s-2*k),min(s,k)+1):#xはmax(0,s-2*k)からmin(s,k)までの値をとる
    l.append(min(s-i,k)+1-max(0,s-(i+k)))
    #for j in range(max(0,s-(i+k)),min(s-i,k)+1):
        
#print(l)
print((sum(l)))

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

#xはmax(0,s-2*k)からmin(s,k)までの値をとる　min(s,k)+1-max(0,s-2*k)通り
#xを決めた時、yはmax(0,s-(x+k)からmin(s-x,k)までの値をとる　min(s-x,k)+1-max(0,s-(x+k))通り
#x,yを決めた時、zは一意　1通り


l=[]
for i in range(max(0,s-2*k),min(s,k)+1):
    l.append(min(s-i,k)+1-max(0,s-(i+k)))
    
print((sum(l)))
# 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()))
count = 0
for x in range(K + 1):
  for y in range(K + 1):
    for z in range(K + 1):
      total = x + y + z
      if total == 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
k,s = [int(i) for i in input().split()]
r=0

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

print(r)


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

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

print(r)
# Original solution
K , S = list(map(int,input().split()))
k = 0
for i in range(K+1):
  for j in range(min([S-i+1,K+1])):
    for l in range(K+1):
      if i + j + l == S:
        k += 1
        break
print(k)        

# Optimized solution
K , S = list(map(int,input().split()))
k = 0
for i in range(K+1):
  for j in range(min([S-i+1,K+1])):
    if 0 <= S - i - j <= K:
      k += 1
print(k)
# Original solution
# vim: set fileencoding=utf-8 :
k, s = list(map(int, input().split()))
patterns = []

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

ct = len(patterns)
print(ct)


# Optimized solution
# vim: set fileencoding=utf-8 :
k, s = list(map(int, input().split()))
patterns = []
ct = 0

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

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

d = {}
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if(z >= 0 and z <= k):
            key = (x,y,z)
            d[key] = 1

print((len(d)))


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

d = {}
cnt = 0
for x in range(k+1):
    for y in range(x+1):
        z = s - x - y
        if(z >= 0 and z <= y):
            if(x == y and y == z):
                cnt += 1
            elif(x == y or y == z or z == x):
                cnt += 3
            else:
                cnt += 6

print(cnt)
# Original solution
k,s = input().split(' ')
k,s = int(k),int(s)


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

print(count)

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


count = 0
for i in range(k+1):
	if i > s:
		break
	for j in range(k+1):
		if i+j > s:
			break
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1

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


count = 0
for i in range(k+1):
	if i > s:
		break
	for j in range(k+1):
		if i+j > s:
			break
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1

print(count)

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


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

# Optimized solution
k,s=list(map(int,input().split()))
print((sum(0<=s-y-z<=k for y in range(k+1) for z in range(k+1))))
# 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):
    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()))
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=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=ans+1
print(ans)
# Original solution
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        z = s - x - y
        if x <= k and y <= k and z <= k and z >= 0:
                count +=1



print(count)


# Optimized solution
from sys import stdin
lis =[]
#k = int(stdin.readline().rstrip())
lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        z = s - x - y
        if z <= k and z >= 0:
                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 S == x+y+z:
                count+=1

print(count)           

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

for x in range(K+1):
    for y in range(K+1):
        countb+=1
        if 0 <= S - (x+y) <= 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
            elif(x+y+z)>s:
                break
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
# 蟻本1-6-1例題相当
# 数学的に解けそうであるが、とりあえず3重のfor文で回してみる
# 最大で2500^3≒100億となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

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

# Optimized solution
# 蟻本1-6-1例題相当
# 続いて、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

count = 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:
        count += 1
print(count)
# Original solution
# 蟻本1-6-1例題相当
# 続いて、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

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

# Optimized solution
# 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する

k, s = list(map(int,input().split()))
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
  ymin = (s - k - x) if (s - k - x) > 0 else 0
  ymax = k if k < s - x else s - x
  for y in range(ymin, ymax+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)
# Original solution
# 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する

k, s = list(map(int,input().split()))
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
  ymin = (s - k - x) if (s - k - x) > 0 else 0
  ymax = k if k < s - x else s - x
  for y in range(ymin, ymax+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)

# Optimized solution
# 蟻本1-6-1例題相当
# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。
# よって1重のfor文で回してみる
# 最大で2500となる
# 今回は、xの取りうる範囲を考慮しない

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

ans = 0

for a in range(0, k+1):
    for b in range(0, k+1):
        for c in range(0, k+1):
            if a+b+c == 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
a = input().split()
k = int(a[0])
s = int(a[1])
count = 0
for n1 in range(k+1):
    for n2 in range(k+1):
        for n3 in range(k+1):
            if n1+n2+n3==s:
                count += 1

print(count)

# Optimized solution
a = input().split()
k = int(a[0])
s = int(a[1])
count = 0
for n1 in range(k+1):
    for n2 in range(k+1):
        if 0<=(s - n1 - n2)<=k:
            count += 1

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

# Optimized solution
K, S = list(map(int, input().split()))
res = 0
for x in range(K+1):
    y_z = S - x
    if y_z < 0:
        continue
    
    y_min = max(y_z-K,0)
    y_max = min(y_z,K)
    res += max(y_max-y_min+1,0)

print(res)
# Original solution
def main():
    ans = 0
    a,b = list(map(int,input().split()))
    for x in range(a+1):
        for y in range(a+1):
            if x+y == b:
                ans += 1
            elif  x + y < b:
                for z in range(a+1):
                    if x + y + z == b:
                         ans += 1
                    elif x + y + z > b:
                        break

    return ans

print((main()))


# Optimized solution
def main():
    ans = 0
    a,b = list(map(int,input().split()))
    for x in range(a+1):
        for y in range(a+1):
            z = b-x-y
            if 0<=z and z<=a:
                ans += 1



    return ans

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

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

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

print(count)
# Original solution
k, s = [int(i) for i in input().split()]
print(([a + b + c == s for a in range(k + 1) for b in range(k + 1) for c in range(k + 1)].count(True)))

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

# Optimized solution
N,M=list(map(int,input().split()))
counter=0
for a in range(N+1):
  for b in range(N+1):
    if 0<=M-(a+b)<=N:
      counter+=1
print(counter)
# Original solution
k,s=list(map(int,input().split()))
print((sum(x+y+z==s for x in range(k+1) for y in range(k+1) for z in range(k+1))))

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

print(res)
# 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 0<= i <= K and 0<= j <= K and 0<=k<=K and 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
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()))

cnt = []
for a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt.append(S-a-b)
        
print((len(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 S-a-b>=0 and S-a-b<=K:
      cnt += 1
        
print(cnt)
# Original solution
k, s = list(map(int,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
                break
            elif x + y + z > s:
                break

print(counter)

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