CodeEff/ECCO huggingface dataset:
# 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()))
count1 = 0
count2 = 0
count3 = 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 and z==x:
                    count1+=1
                elif x!=y and y!=z and z!=x:
                    count2+=1
                else:
                    count3+=1
sum = count1+count2*6+count3*3
print(sum)

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

        if z>=0 and z<=K:
            sum+=1


print(sum)
# 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>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()))
r=K+1
count=0
for x in range(r):
  if x>S:
    break
  for y in range(r):
    if y>S:
      break
    z=S-x-y
    if 0<=z and z<=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<=k:
            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):
    z=s-i-j
    if 0<=z<=k:
      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 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 and 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(x,k+1):
        for z in range(y,k+1):
            if x+y+z == s:
                if x == y and y == z:
                    count += 1
                elif x == y or y == z or x == z:
                    count += 3
                else:
                    count += 6
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 0 <= z:
            count += 1
print(count)
# Original solution
k,s=list(map(int,input().split()))
upper  = min(k,s)+1
lower = max(0,s-2*k)
ans = 0
for i in range(lower,upper):
  for j in range(lower,upper):
    if i + j > s:
      break
    for k in range(lower,upper):
      if i+j+k == s:
        ans += 1
        break
print(ans)

# Optimized solution
k,s=list(map(int,input().split()))
upper  = min(k,s)+1
lower = max(0,s-2*k)
ans = 0
for i in range(lower,upper):
  for j in range(lower,upper):
    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(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
cnt=0
k,s=list(map(int,input().split()))
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()))
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(k+1):
    if x==s:
        count+=1
    elif x+2*k>=s:
        for y in range(k+1):
            if x+y==s:
                count+=1
            elif x+y+k>=s:
                for z in range(k+1):
                    if x+y+z==s:
                        count+=1
                        break
print(count)

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

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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k < 0 or k > K:
            continue
        if i+j+k == S:
            cnt += 1
print(cnt)

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

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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)
# Original solution
import sys
k,s=list(map(int,input().split()))
sati=0
for i in range(k+1):
  for j in range(k+1):
    for z in range(k+1):
      suma=i+j+z
      if suma==s:
        sati+=1
      suma=0
print(sati)

# 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 and z % 1 == 0):
            ans += 1

print(ans)
# Original solution
k, s = list(map(int, input().split()))
li = []
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if z == s - (x + y):
                li.append('{} {} {}'.format(x, y, z))
li
print((len(set(li))))

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

pair = list()

for x in range(limit + 1):
    y_limit = 0
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        pair.append([x, y, z])
ans = len(pair)

print(ans)

# Optimized solution
import sys
input = sys.stdin.readline
 
def main():
    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 z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()
# Original solution
limit, sum_xyz = list(map(int, input().split()))

pair = list()

for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        else:
            pair.append([x, y, z])
ans = len(pair)

print(ans)

# Optimized solution
limit, sum_xyz = list(map(int, input().split()))

pair = list()

ans = 0
for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        else:
            ans += 1
print(ans)
# Original solution
K, S = list(map(int, input().split()))

L = [x + y + z
    for z in range(K+1)
    for y in range(K+1)
    for x in range(K+1)
    ]
print((L.count(S)))

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

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

cnt = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + j + k == S: cnt += 1
print (cnt)


  

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

L = [1 for z in range(K+1) for y in range(K+1) if 0 <= S-y-z <= K]
print((L.count(1)))
# Original solution
import itertools

"""
整数K,S
2 <= K <= 2500, 0 <= S <= 3K

0 <= X,Y,Z <= K
X + Y + Z = Sを満たすX,Y,Zの割り当ては何通り？

"""
K, S = list(map(int, input().strip().split(' ')))
X = list(range(K + 1))
Y = list(range(K + 1))
Z = list(range(K + 1))
count = 0

for i, j, k in list(itertools.product(X,Y,Z)):
  if i + j + k == S:
    count += 1
print(count)

# Optimized solution
import itertools

K, S = list(map(int, input().strip().split(' ')))
X = list(range(K + 1))
count = 0
for i, j in itertools.product(X, repeat=2):
  if 0 <= S - i - j <= K:
    count += 1
print(count)
# Original solution
import itertools

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

X = list(range(K + 1))
Y = list(range(K + 1))
Z = list(range(K + 1))

count = 0
for i, j, k in itertools.product(X, Y, Z):
  if i + j + k == S:
    count += 1
print(count)

# Optimized solution
import itertools

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

X = list(range(K + 1))
Y = list(range(K + 1))
Z = list(range(K + 1))

count = 0
for i, j in itertools.product(X, Y):
  if S - i - j in Z:
    count += 1
print(count)
# Original solution
K,S = list(map(int,input().split()))
num = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k) == S: num += 1
print(num)

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

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

ans = 0

if k * 3 == s:
    print((1))
    exit(0)
else:
    for v in range(k + 1):
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if hoge < 0 or hoge > k:
                    pass
                else:
                    ans += 1
                    
print(ans)




# Optimized solution
# import bisect

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

ans = 0

if k * 3 == s:
    print((1))
    exit(0)
else:
    for v in range(k + 1):
        # bisect.bisect_left([i for i in range(2 * k + 1)], s - v)
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                # hoge = bisect.bisect_left([i for i in range(k + 1)], targ)
                if targ < 0 or targ > k:
                    pass
                else:
                    ans += 1

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

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

print(cnt)


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

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

print(cnt)
# Original solution

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

count = 0

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

print(count)

# Optimized solution

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

count = 0

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

print(count)


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

print(count)
# Original solution
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc009/tasks/abc51_2
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

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

count = 0
for X in range(0, min(S + 1, K + 1)):
    for Y in range(0, min(S + 1, K + 1)):
        for Z in range(0, min(S + 1, K + 1)):
            if X + Y + Z == S:
                count += 1
print(count)                









# Optimized solution
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc009/tasks/abc51_2
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

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

count = 0
for X in range(0, min(S + 1, K + 1)):
    for Y in range(0, min(S + 1, K + 1)):
        Z = S - X - Y
        if 0 <= Z <= K:
            count += 1
print(count)
# Original solution
k,s=list(map(int,input().split()))
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if z<0:
            break
        if 0<=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()))
count=0
for x in range(k+1):
    for y in range(x+1):
        for z in range(y+1):
            if x+y+z==s:
                if x==y==z:
                    count+=1
                elif x==y or y==z or z==x:
                    count+=3
                else:
                    count+=6
print(count)







# Optimized solution
k,s=list(map(int,input().split()))
count=0
for x in range(k+1):
    for y in range(x+1):
        if x+y>s:
            continue
        else:
            z=s-x-y
            if z>x or z>y:
              continue
            if x==y==z:
                count+=1
            elif x==y or y==z or z==x:
                count+=3
            else:
                count+=6
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
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)

# Optimized solution
K, S = list(map(int, input().split()))
count = 0
for i in range(K + 1):
    if 0 <= S - i < K:
        count += S - i + 1
    elif K <= S - i <= 2 * K:
        count += 2 * K - S + i + 1
    else:
        continue
print(count)
# Original solution
k, s = list(map(int, input().split()))
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            if i + j + l == s:
                count += 1
print(count)

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


# Optimized solution
k,s = list(map(int,input().split()))
total = 0
for i in range(k+1):
    for j in range(k+1):
        if (i+j > s) or (s-i-j > k):
            continue
        else:
            total += 1
print(total)
# Original solution
K,S = list(map(int,input().split()))
count = 0
for p in range(K+1):
    for q in range(K+1):
        for r in range(K+1):
            if p+q+r == S:
                count+=1
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):
        if S-p-q>=0 and S-p-q <= K:
            count+=1
print(count)
# Original solution
k,s=list(map(int,input().split()))
count=0

nums=[i for i in range(k+1)]

for i in range(len(nums)):
  for j in range(len(nums)):
    l = s-i-j
    if 0 <= l <=k:
      if i+j+l==s:
        count+=1
print((count))


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

nums=[i for i in range(k+1)]

for i in range(len(nums)):
  for j in range(len(nums)):
    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):
        for z in range(k+1):
            if x + y + z == s:
                cnt = cnt + 1

print(cnt)

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

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - (x + y)
        if z >= 0 and z <= k:
            cnt = cnt + 1
#        for z in range(k+1):
#            if x + y + z == s:
#                cnt = 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(S-x+1):
        if y <= K:
            z = S - x - y
            if z >= 0 and z <= K:
                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(min(K,S-x)+1):
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)
# Original solution
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(K+1):
            if x+y > S:
                break
            for z in range(K+1):
                if x+y+z > S:
                    break
                if S == x+y+z:
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


# Optimized solution
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 0
    for x in range(K+1):
        if x > S:
            break
        for y in range(K+1):
            if x+y > S:
                break
            z = S-(x+y)
            if z < 0 or z > K:
                continue
            # print(x,y,z)
            if S == x+y+z:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
# Original solution
def main():
    k, s = list(map(int, input().split()))

    pattern = 0

    if s > 3 * k:
        print(pattern)
        return

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

    print(pattern)


if __name__ == "__main__":

    main()


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

    pattern = 0

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

    # Wrong Anser
    # 
    # # 3,4 --> 0 start
    # # 3,5 --> 0 start
    # # 3,7 --> 1 start
    # # 3,8 --> 2 start
    # # 3,9 --> 3 start 
    # # 4,8 --> 0 start
    # # 4,9 --> 1 start
    # # 4,10 --> 2 start
    # # s // k * 2
    # 
    # for x in range(s // 3, k + 1):
    #     for y in range(s // 3, min(k + 1, s - x + 1)):
    #         for z in range(s // 3, min(k + 1, s - x - y + 1)):
    #             if x + y + z == s:
    #                 pattern += 1
    # 

    print(pattern)


if __name__ == "__main__":

    main()
# Original solution
K, S = list(map(int, input().split()))
Y = 0

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

print(Y)

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

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

print(Y)
# Original solution
k, s = list(map(int, input().split()))
ans = 0
if s <= k:
    ans = (s+2)*(s+1) / 2
elif k < s <= 2*k:
    for i in range(k+1):
        j = s-k+i
        if j <= k:
            ans += j+1
        else:
            ans += j+1-2*(j-k)
elif 2*k < s < 3*k:
    ans = 3
else:
    ans =  1
print((int(ans)))


# Optimized solution
k, s = list(map(int, input().split()))
if 0 <= s <= k:
    ans = (s+1)*(s+2)/2
    print((int(ans)))
elif k < s <= 2*k:
    ans = ((s+1)*(s+2)/2) - ((s-k)*(s-k+1)/2) - ((s-k)*(s-k+1))
    print((int(ans)))
elif 2*k < s < 3*k:
    print((3))
else:
    print((1))
# Original solution
from itertools import product
k, s = list(map(int, input().split()))
numbers = list(product([i for i in range(k+1)], repeat=2))
ans = 0
for x, y in numbers:
    if x + y > s:
        continue
    if x + y == s:
        ans += 1
    elif x + y < s:
        for z in range(k+1):
            if x + y + z == s:
                ans += 1
                break
print(ans)

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

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


print(idx)


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

idx = 0


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

print(idx)
# Original solution
N,M = input().split()
N = int(N)
M = int(M)

sum = 0

for i in range(N + 1):
    for j in range(N + 1):
        for k in range(N + 1):
            if i + j + k == M:
                sum += 1
            
print(sum)

# Optimized solution
N,M = input().split()
N = int(N)
M = int(M)

sum = 0

for i in range(N + 1):
    for j in range(N + 1):
        if  0 <= M - i - j <= N:
            sum += 1
            
print(sum)
# Original solution
I = list(map(int, input().split()))
K, S = I[0], I[1]

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
I = list(map(int, input().split()))
K, S = I[0], I[1]

print((len([0 for i in range(K+1) for j in range(K+1) if 0<=S-i-j<=K])))
# Original solution
#ABC951B/Sum_of_Three_Integers

K, S = list(map(int, input().split()))
ans = 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 and X + Y + Z == S:
                ans += 1
            elif X == Y and X + Y + Z == S:
                ans += 3
            elif Y == Z and X + Y + Z ==S:
                ans += 3
            elif X + Y + Z == S:
                ans += 6
print(ans)

# Optimized solution
#ABC951B/Sum_of_Three_Integers

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
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):
        cnt += 1
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):
    n = s - l - m
    if 0 <= n <= k:
      cnt += 1
print(cnt)