CodeEff/ECCO huggingface dataset:
# 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>s or y>s or z>s or x+y>s or x+z>s or y+z>s:
        continue
      elif 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<=k:
      count+=1
      
print(count)
# Original solution
[K, S] = list(map(int, input().split()))
ret = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if (x + y + z) == S:
                ret += 1
print(ret)


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

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

# Optimized solution
K,S=list(map(int,input().split()))
point=0
for i in range(K+1):
  for j in range(K+1):
    if 0<=S-i-j<=K:
      point+=1
print(point)
# Original solution
k,s = [int(x) for x in input().split()]
a = 0
n = 0
while a <= k:
  b = 0
  while b <= k:
    c = 0
    while c <= k:
      if (a+b+c) == s:
        n += 1
      c += 1
    b += 1
  a += 1
print(n)


# Optimized solution
k,s = [int(x) for x in input().split()]
a = 0
n = 0
while a <= k:
  b = 0
  while b <= k:
    z = s-a-b
    if 0<=z and z <= k:
      n += 1
    b += 1
  a += 1
print(n)
# Original solution
k, s = input().split()
k, s = int(k), int(s)
ans = 0
for i1 in range(k+1):
  for i2 in range(k+1):
    for i3 in range(k+1):
      if i1 + i2 + i3 == s:
        ans += 1
print(ans)

# Optimized solution
k, s = input().split()
k, s = int(k), int(s)
ans = 0
for i1 in range(k+1):
  for i2 in range(k+1):
      if i1 + i2 <= s <= i1 + i2 + k:
        ans += 1
print(ans)
# Original solution
def solve():
    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
    return c

print((solve()))


# Optimized solution
def solve():
    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:
                z = S-(x+y)
                if x+y+z == S:
                    c += 1
    return c

print((solve()))
# Original solution
k,s = list(map(int,input().split()))
print((sum([1 for a in range(k+1) for b in range(k+1) for c in range(k+1) if a+b+c == s])))

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

print(ans)
# Original solution
import itertools
k,s=list(map(int,input().split()))
count=0
ans=list(itertools.product(list(range(k+1)),repeat=3))
for i in ans:
    if sum(i)==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()))
n = 0
for x in range(K+1):
  for y in range(K+1):
    if x+y > S:
      break
    for z in range(K+1):
      if x+y+z == S:
        n += 1
      elif x+y+z > S:
        break
print(n)

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

# Optimized solution
a,b=list(map(int,input().split()))
ans=0
for i in range(a+1):
    for j in range(a+1):
        if 0<=(b-i-j)<=a:
                ans+=1
print(ans)
# Original solution
import sys


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

min_num = s - k * 2
if min_num <= 0:
    min_num = 0

ans = 0

for x in range(min_num, k + 1):
    for y in range(min_num, k + 1):
        z = s - x - y
        if z > k or z < 0:
            continue
        else:
            ans += 1

print(ans)

# Optimized solution
import sys


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

# min_num = s - k * 2
# if min_num <= 0:
min_num = 0

ans = 0

for x in range(min_num, k + 1):
    for y in range(min_num, k + 1):
        z = s - x - y
        if z > k or z < 0:
            continue
        else:
            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 f in range(K+1):
            if i + j + f == 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()))
cnt=0
for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l+m+n==s and l<=k and m<=k and n<=k:
                cnt+=1
                #print(l,m,n)
print(cnt)

# Optimized solution
k,s=list(map(int,input().split()))
cnt=0
for l in range(k+1):
    for m in range(k+1):
        #2つが定まるともう一つの値は一意に定まる
        if 0<=s-l-m and s-l-m<=k:
            cnt+=1
            #print(l,m,n)
print(cnt)
# Original solution
a, b = list(map(int, input().split()))
count = 0
for i in range(a+1):
    for j in range(a+1):
        for k in range(a+1):
            if i + j + k == b:
                count += 1
print(count)

# Optimized solution
a, b = list(map(int, input().split()))
c = a+1
count = 0
for i in range(c):
    for j in range(c):
        if 0 <= (b - i - j) <= a:
            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):
        if 0 <= S - (i + j) <= K:
            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()))
p = 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:
                p += 1
            if x + y + z > S:
                break
print(p)

# Optimized solution
K, S = list(map(int,input().split()))
p = 0
for x in range(K+1):
    if S-x <= 2*K:
        for y in range(min(S-x+1,K+1)):
            if S-x-y <= K:
                p += 1
print(p)
# Original solution
k,s=[int(i) for i in input().split()]
ans=0
chk=set([])
for i in range(k+1):
    for j in range(i,k+1):
        tmp=s-i-j
        x=[i,j,tmp]
        x.sort()
        x=tuple(x)
        if 0<=tmp<=k and x not in chk:
            chk.add(x)
            if i==j==tmp:
                ans+=1
            elif i==j or i==tmp or j==tmp:
                ans+=3
            else:
                ans+=6
print(ans)

# Optimized solution
k,s=[int(i) for i in input().split()]
ans=0
chk=set([])
for i in range(k+1):
    for j in range(i,k+1):
        tmp=s-i-j
        if 0<=tmp<=k and i<=j<=tmp:
            if i==j==tmp:
                ans+=1
            elif i==j or i==tmp or j==tmp:
                ans+=3
            else:
                ans+=6
print(ans)
# Original solution
k,s=list(map(int,input().split()))
ans=chk=0
for i in range(k+1):
    for j in range(k+1):
        if (0<=s-i-j<=k): ans+=1
print(ans)

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

cnt = 0
K += 1

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

print(cnt)

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

cnt = 0
K += 1

#TLE CODE
'''
for x in range(K):
    for y in range(K):
        for z in range(K):
            if x + y + z == S:
                cnt += 1
'''

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

print(cnt)
# Original solution
K, S = list(map(int,input().split()))
X = 0
Y = 0
Z = 0
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 = 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 <= K and z >= 0:
      count = count + 1
print(count)
# Original solution
k, s = list(map(int, input().split()))
ans = []
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        h = s- i- j
        if 0<= h <= k:
            ans.append([i, j, h])
print((len(ans)))

# Optimized solution
k, s = list(map(int, input().split()))
cnt = 0
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        h = s- i- j
        if 0<= h <= 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):
        if(0<=s-x-y<=k):
            count+=1
        else:continue
print(count)

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

result = 0

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

print(result)

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

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

    return count

print((fun(k, s)))
# Original solution
import itertools
k, s = list(map(int, input().split()))
ans = 0
for i in list(itertools.product(list(range(k + 1)), repeat=3)):
    if sum(i) == 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()))
c=0
#x>=y>=z
for i in range(k+1):
    for j in range(i+1):
        for k in range(j+1):
            if i+j+k==s:
                if i==j==k:
                    c+=1
                elif i!=j and j!=k:
                    c+=6
                else:
                    c+=3
                
print(c)

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

input = sys.stdin.readline


class AtCoder:
    def main(self):
        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)

if __name__ == '__main__':
    AtCoder().main()

# Optimized solution
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        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)


if __name__ == '__main__':
    AtCoder().main()
# 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-i-j <= K and S-i-j>=0):count+=1

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

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

ans = 0
b = []
for i in range(k+1):
    for j in range(k+1):
        if i + j <= s:
            b.append(i+j)

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

print(count)
# Original solution
k,s = list(map(int, input().split()))
a = b = c = d = 0
for x in range(k+1):
    if 3*x == s:
        a += 1
        break

for x in range(k+1):
    for z in range(x):
        if 2*x + z == s:
            b += 1
b *= 3
for x in range(k+1):
    for y in range(x):
        if x + 2*y == s:
            c += 1
c *= 3

for x in range(k+1):
    for y in range(x):
        for z in range(y):
            if x+y+z == s:
                d += 1
d *= 6

print((a+b+c+d))



# Optimized solution
k,s = list(map(int, input().split()))
ans = 0
for p in range(min(k+1,s+1)):
    for q in range(p, s+1):
        if q-p > k or s - q > k:
            continue
        else:
            ans += 1
print(ans)
# Original solution
#051_B
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
#051_B
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)])))
# Original solution
K, S = list(map(int, input().split()))

out = 0

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


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

out = 0

# 全探査だと間に合わない
# zはあるかないかの２択なので外せる
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
            out += 1
print(out)
# Original solution
K,S = list(map(int,(input().split())))

n = 0

for x in range(K+1) :
        if (S - x <= 2 * K):
                for y in range(K+1) :
                        if (K >= x) and (K >= y) and (S >= x + y) and (S-x-y <= K):
                                n = n + 1

                
print(n)

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

n = 0

for x in range(K+1) :
        if (S - x <= 2 * K):
                for y in range(K+1) :
                        if 0 <=S-x-y <= K:
                                n += 1

                
print(n)
# 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 K>=S-(X+Y) and X+Y<=S:
      cnt=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):
        if 0 <= S-(x+y) <= K:
            count +=1

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


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



# Optimized solution
k,s=[int(i) for i in input().split()]
c=0
for i in range(k+1):
    for j in range(k+1):
        l=s-(i+j)
        if(0<=l<=k):
            c+=1
print(c)
# Original solution
# -*- coding: utf-8 -*-
K, S = list(map(int, input().split()))
ans = 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 len(set([X, Y, Z])) == 1:
                    ans += 1
                elif len(set([X, Y, Z])) == 2:
                    ans += 3
                else:
                    ans += 6
print(ans)

# Optimized solution
# -*- coding: utf-8 -*-
K, S = list(map(int, input().split()))
ans = 0

for X in range(K + 1):
    for Y in range(X, K + 1):
        Z = S - Y - X
        if Z >= Y and Z <= K:
                
            if len(set([X, Y, Z])) == 1:
                ans += 1
            elif len(set([X, Y, Z])) == 2:
                ans += 3
            else:
                ans += 6
print(ans)
# Original solution
k,s=list(map(int,input().split()))
ans=0
for i in range(k+1):
     for n in range(k+1):
         for t in range(k+1):
            if i+n+t==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):
        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()))
ans = 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 == z:
          ans += 1
        elif x == y or y == z:
          ans += 3
        else:
          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(k+1):
    if 0 <= s - i - j <= k:
      ans += 1
      
print(ans)
# 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):
        for z in range(0, 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()))
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 x in range(K+1):
    for y in range(K+1):
        if (S-(x+y) <= K)&(S-(x+y) >= 0):
            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)&(z<=K):
            count += 1
print(count)
# Original solution
# -*- coding: utf-8 -*-
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 += 1

print(count)

# Optimized solution
# -*- coding: utf-8 -*-
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):
  if X > S and 3*K < S:
    break
  for Y in range(K+1):
    add_xy = X + Y
    if S < add_xy and add_xy < (2/3) * S:
      break
    Z = S - X - Y
    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 = list(map(int, input().split()))
count = 0
for x in range(0, K + 1):
	if (x > S):
		break
	for y in range(0, K + 1):
		if (x + y > S):
			break
		for z in range(0, K + 1):
			if (x + y + z == S):
				count = count + 1
			elif (x + y + z > S):
				break
print(count)


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

print(count)