CodeEff/ECCO huggingface dataset:
# Original solution
# coding: utf-8
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)


# Optimized solution
# coding: utf-8
K, S = list(map(int, input().split()))
cnt=0
for x in range(K+1):
        yz = S - x
        if yz < 0:
                break
        elif yz > 2*K:
                continue
        else:
                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()))

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 a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=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 z <= k and z >= 0:
      ans += 1
print(ans)
# Original solution
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

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

# Optimized solution
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

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
x, y  =input().split(' ')
count = 0
for i in range(int(x)+1):
    for j in range(int(x)+1):
        for k in range(int(x)+1):
            if i + j + k == int(y):
                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 s<=k+i+j:
            count += 1

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

answer = 0

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

print(answer)

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

answer = 0

for i in range(K + 1):
    for j in range(K + 1):
        if 0 <= S - i - j <= K:
            answer += 1

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

# Optimized solution
K, S = list(map(int, input().split()))
cnt = 0
from itertools import product as prd
for x, y in prd(list(range(K+1)),list(range(K+1))):
    if 0 <= S-x-y <= K:
        cnt += 1
print(cnt)
# Original solution
K , S = list(map(int , input().split()))
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                cnt +=1

print(cnt)

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

print(cnt)
# Original solution
import itertools

K,S = list(map(int,input().split()))
l = set(range(K+1))
ans = 0

for x, y, z in itertools.product(l,l,l):
    if x + y + z == S:
        ans += 1

print(ans)

# Optimized solution
import itertools

K,S = list(map(int,input().split()))
l = set(range(K+1))
ans = 0

for x, y in itertools.product(l,l):
    if x + y + K >= S and x + y <= S:
        ans += 1

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

def main():
    K,S = list(map(int, input().split()))
    n = 0
    for i in range(K+1):
        x = min(K+1, S-i+1)
        for j in range(x):
            y = min(K+1, S-i-j+1)
            for k in range(y):
                if i+j+k == S:
                    n += 1
    print(n)

if __name__ == '__main__':
    main()


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

def main():
    K,S = list(map(int, input().split()))
    n = 0
    for i in range(K+1):
        for j in range(K+1):
            if S-i-j >= 0 and S-i-j <= K:
                n += 1
    print(n)

if __name__ == '__main__':
    main()
# Original solution
import itertools

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

print((sum([1 for xyz in itertools.product(list(range(K + 1)), repeat=3) if sum(xyz) == S])))


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

def f():
  if K * 3 >= S:
    for x in range(min(K, S), -1, -1):
      if K * 2 >= S - x:
        for y in range(min(K, S - x), -1, -1):
          if K >= S - x - y:
            yield 1

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

same_all = 0
same_two = 0
same_none = 0
K += 1

for i in range(1, K):
    if(i == S):
        same_two += 1
        
    for j in range(i,K):
        if (i + j == S):
            if (i == j):
                same_two += 1
            else:
                same_none += 1
            
        for k in range(j,K):
            if (i + j + k == S):
                if (i == j) and (j == k):
                    same_all += 1
                elif (i == j) or (j == k) or (i == k):
                    same_two += 1
                else:
                    same_none += 1                 

print((same_all + same_two*3 + same_none*6))

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

same_all = 0
same_two = 0
same_none = 0

for i in range(K, -1, -1):
    for j in range(S - i, -1, -1):
        if ( K<j or i<j):
            continue
        k = S-i-j
#         print(i,j,k)
        if (k <= K and k<=j):
            if(i == j and j == k):
                same_all += 1
            elif(i == j or i == k or k == j):
                same_two += 1
            else:
                same_none += 1


print((same_all + same_two*3 + same_none*6))
# 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 x+y<=s 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

print(count)

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


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

print(cnt)


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

print(ans)

# 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
# -*- coding: utf-8 -*-

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
# -*- coding: utf-8 -*-

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


# Optimized solution
x = list(map(int, input().split()))
cnt = 0
for i in range(x[0]+1):
  for j in range(x[0]+1):
    p = i+j
    if (p <= x[1]) and (x[0]+p) >= x[1]:
      cnt += 1
print(cnt)
# Original solution
def main():
    k, s = list(map(int, input().split()))
    if s > 3*k:
        pass
    elif s == 3*k:
        ans = 1
    else:
        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)
main()


# Optimized solution
def main():
    k, s = list(map(int, input().split()))
    if s > 3*k:
        pass
    elif s == 3*k:
        ans = 1
    else:
        ans = 0
        for i in range(k+1):
            for j in range(k+1):
                    if 0<=s - (i + j)<=k:
                        ans += 1
    print(ans)
main()
# Original solution
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 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<=S and K+i+j>=S:
            count+=1

print(count)






# Optimized solution
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

#for i in range(K+1):
#    for j in range(K+1):
#        if i+j<=S and K+i+j>=S:
#            count+=1
for i in range(K+1):
    S_rest = S-i
    if S_rest>2*K:
        continue
    if S_rest<0:
        break
    if S_rest>=K:
        count += 2*K- S_rest +1
    else:
        count += S_rest+1

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

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

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)

# 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 x+y+z != s:
      continue
    if z >= 0 and 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(x, k + 1):
    for z in range(y, k + 1):
      if x + y + z == s:
        if x == y and y == z:
          res += 1
        elif x == y or y == z or z == x:
          res += 3
        else:
          res += 6
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 <= k:
      res += 1
print(res)
# Original solution
k,s = list(map(int, input().split(" ")))
sum = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l == s:
                sum += 1
print(sum)

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

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

print(count)
# Original solution
k, s = list(map(int, input().split()))
result = [i_1+i_2+i_3 for i_1 in range(k+1) for i_2 in range(k+1) for i_3 in range(k+1) if i_1+i_2+i_3==s]
print((len(result)))

# Optimized solution
k, s = list(map(int, input().split()))
result = [i_1+i_2 for i_1 in range(k+1) for i_2 in range(k+1) if 0<=s-i_1-i_2<=k]
print((len(result)))
# 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(min(k+1,s + 1)):
    for y in range(x,min(x+k+1,s +1)):
        if s - 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):
        if ((x + y) <= s) and ((s - (x + y)) <= k):
            count += 1
                
print(count)

# Optimized solution
k, s = list(map(int,input().split()))
count= 0
#全探索は時計が切れる
for x in range(k+1):
    for y in range(k+1):
        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):
        if 0 <= s - (x +y) <= k:
            count += 1

print(count)

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

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

count = 0

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

print(count)


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

count = 0
m = K + 1


for x in range(m):
    for y in range(m):
        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()))
count = 0

for p in range(k+1):
    for q in range(min(k+1, s-p+1)):
        for r in range(min(k+1, s-p-q+1)):
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)


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

for p in range(k+1):
    for q in range(k+1):
        r = s-p-q
        if r>=0 and r<=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(i,k+1):
        for k in range(j,k+1):
            if i+j+k == s:
                l = len({i,j,k})
                c += l*(l+1)//2
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):
         c += 1*(0 <= s - i -j <= k)
print(c)
# Original solution
# coding: utf-8
# Your code here!

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

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

print(result)

# Optimized solution
# coding: utf-8
# Your code here!

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

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

print(result)
# Original solution
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        k, s = line.rstrip("\n").split(" ")
        k = int(k)
        s = int(s)
        counter = 0
        for x in range(0, 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 y == z:
                            counter += 1
                        elif x == y or y == z or x == z:
                            counter += 3
                        else: 
                            counter += 6
        print(counter)

if __name__ == "__main__":
    main(sys.argv)

# Optimized solution
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        k, s = line.rstrip("\n").split(" ")
        k = int(k)
        s = int(s)
        counter = 0
        for x in range(0, k + 1):
            for y in range(x, k + 1):
                if x + y <= s:
                    z = s - x - y
                    if z >= y and z <= k:
                        if (x+y+z) == s:
                            if x == y and y == z:
                                counter += 1
                            elif x == y or y == z or x == z:
                                counter += 3
                            else: 
                                counter += 6
        print(counter)

if __name__ == "__main__":
    main(sys.argv)
# Original solution
k, s = list(map(int, input().split()))
cnt = 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:
                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):
        if (0 <= s-x-y) and (s-x-y <= k):
            cnt += 1
print(cnt)
# Original solution
k,s = list(map(int,input().split()))

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

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

t=0
for x in range(k+1):
    for y in range(k+1):
        if s-x-y >= 0 and s-x-y <= k: 
            t+=1
print(t)
# Original solution
from sys import stdin
K, S = list(map(int, stdin.readline().rstrip().split()))
l = list(i for i in range(K+1))
def binary_search(list, item):
    count = 0
    low = 0
    high = len(list) - 1
    while low <= high:
        if (low + high) % 2 == 0:
            mid = (low + high) // 2
        else:
            mid = (low + high) // 2 - 1
        guess = list[mid]
        if guess == item:
            return True
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1
    return None
count = 0
for i in range(K+1):
    for j in range(K+1):
        if binary_search(l, S - i - j):
            count += 1
print(count)
            


# Optimized solution
from sys import stdin
K, S = list(map(int, stdin.readline().rstrip().split()))
l = list(i for i in range(K+1))
count = 0
for i in range(K+1):
    for j in range(K+1):
        z = S - i - j
        if 0 <= z <= K:
            count += 1
print(count)
# Original solution
k,s = list(map(int,input().split()))
count = 0
for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if (i+j+m == 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):
        m = s-j-i
        if(m <= k and 0 <= m):
            #print(i,j,m)
            count += 1

print(count)
# Original solution

l = list(map(int,input().split()))

count = 0

for x in range(l[0] + 1):
    for y in range(l[0] + 1):
        for z in range(l[0] + 1):
            if x + y + z == l[1]:
                count += 1

print(count)


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

import itertools

k, s = list(map(int, input().strip().split()))
result = [i for i in itertools.product(list(range(k+1)), repeat=3) if sum(i) == s]
print((len(result)))


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

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

# Optimized solution
k, s = list(map(int, input().split()))
count = 0
for kx in range(0, k+1):
    for ky in range(0, k+1):
        kz = s - kx -ky
        if 0 <= kz <= k:
            count += 1
print(count)