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

n = []
for i in range(K + 1):
  n.append(i)

import itertools
XYZ = list(itertools.product(n, repeat = 3))

count = 0
for j in range(len(XYZ)):
  if sum(XYZ[j]) == S:
    count += 1

print(count)

# Optimized solution
K, S = list(map(int, input().split()))
n = []
for i in range(K + 1):
  n.append(i)

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

for i in range(0,k+1):
    for j in range(0,k+1):
        x = i
        y = j
        z = s-i-j
        ##print("X=" + str(x),"Y=" + str(y),"Z="+ str(z))
        if 0<= z <= k:
          count+=1
print(count)

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

# 組み合わせをカウントする変数
count = 0

# 変数の初期化
x = 0
y = 0
z = 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()))
# print(k)
# print(s)

# 組み合わせをカウントする変数
count = 0

# 変数の初期化
x = 0
y = 0
z = 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()))
print(([x+y+z for z in range(k+1) for y in range(k+1) for x in range(k+1)].count(s)))

# 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-z-y<=k])))
# Original solution
import itertools
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
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):
      if 0 <= S-(i+j) <= K:
        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):
            if x + y + z == S:
                count += 1

print(count)

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

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

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

ans = 0
for 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 K >= S - x - y and z >= 0:
                ans += 1

print(ans)
# Original solution
from itertools import product as prod

k, s = [int(x) for x in input().split()]

x = list(range(k + 1))
y = list(range(k + 1))
z = list(range(k + 1))
c = 0
for x, y, z in prod(x, y, z):
    if x + y + z == s:
        c += 1

print(c)

# Optimized solution
from itertools import product as prod

k, s = [int(x) for x in input().split()]

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

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

print(ans)

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

# Optimized solution
K, S = [int(x) for x in input().split()]
count = 0
for x in range(K+1):
    # y + z = S - x
    if 0 <= S - x <= K: 
        count += S - x + 1 
        # yに選べるのは0から(y+z)までのy+z-0+1通りすなわちS-x+1
    elif K < S - x <= 2 * K:
        count += 2 * K - S + x + 1 
        # K - ((S - x) - K) + 1
        # excess = (S-x)-K
    else: 
        # S-x > 2Kだと、y+z > 2Kとなり、
        # こうなる組みは存在しない
        continue
print(count)
# Original solution
#                         author:  kagemeka 
#                         created: 2019-11-08 23:31:18(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k * 2:     # s - x = y + z
            for y in range(k + 1):
                if 0 <= s - x - y <= k:
                    count += 1
    
    print(count)


if __name__ == "__main__":
    # execute only if run as a script
    main()


# Optimized solution
#                         author:  kagemeka 
#                         created: 2019-11-08 23:31:18(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k:
            count += s - x  + 1
        elif k < s - x <= 2 * k:
            count += k - (s - x - k) + 1

    
    print(count)


if __name__ == "__main__":
    # execute only if run as a script
    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 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):
        l = s - i - j
        if l >= 0 and l <= k:
            count += 1

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

# Optimized solution
k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0<= z <= k:
            count += 1
print(count)
# Original solution
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = list(map(int, input().split()))
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

TLEになったので、もう少し節約するパターンを考える必要あり
ひとまずx,x+y,x+y+zがsより大きなった場合はbreakさせてループを抜ける処理にしてみる

"""


def solve(k, s):
    pattern = 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:
                    pattern += 1

    return pattern


if __name__ == "__main__":
    main()


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

def main():
    stdIn1, stdIn2 = list(map(int, input().split()))
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

TLEになったので、もう少し節約するパターンを考える必要あり
ひとまずx,x+y,x+y+zがsより大きなった場合はbreakさせてループを抜ける処理にしてみる
まだTLEになるので、もう少し考える
実はzはループする必要はなく z = s - (x + y) <= k であれば +1, > k であれば continueでよい
これでO(N^2)に計算量を抑えられる

"""


def solve(k, s):
    pattern = 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 <= k:
                pattern += 1

    return pattern


if __name__ == "__main__":
    main()
# Original solution
K,S=input().split()
K=int(K)
S=int(S)
A=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:
                A=A+1
print(A)

# Optimized solution
K,S=input().split()
K=int(K)
S=int(S)
A=0
for x in range(0,K+1):
    for y in range(0,K+1):
        z=S-x-y
        if 0<=z<=K:
            A=A+1
print(A)
# Original solution
K, S = list(map(int, input().split()))
ct = 0
for X in range(K+1):
  if S - X > 0:
    for Y in range(K+1):
      if S - (X + Y) > 0:
        for Z in range(K+1):
          ct += (1 if X + Y + Z == S else 0)
      else:
        ct += (1 if X + Y == S else 0)
  else:
    ct += (1 if X == S else 0)
print(ct)

# Optimized solution
K, S = list(map(int, input().split()))
ct = 0
for X in range(K+1):
  for Y in range(K+1):
    if S - (X + Y) >= 0 and S - (X + Y) <= K :
        ct += 1 

print(ct)
# Original solution
K, S = list(map(int, input().split()))
ct = 0
for X in range(K+1):
  for Y in range(K+1):
    if S - (X + Y) >= 0 and S - (X + Y) <= K :
        ct += 1 

print(ct)

# Optimized solution
K, S = list(map(int, input().split()))
ans = 0
for Z in range(K+1):
  r = S - Z
  if r < 0:
    ans += 0
  elif r <= K:
    ans += r+1
  elif r <= K*2:
    ans += (K+1)*2 - (r+1)
print(ans)
# Original solution
import math
K,S = list(map(int, input().split()))
n = 0
up = math.floor(K)
for i in range(up+1):
    for j in range(i,up+1):
        for k in range(j,up+1):
            if i==j and j==k:
                same=1
            elif (i==j and j!=k)or(j==k and i!=j) or(k ==i and i!=j):
                same =3
            else:
                same =6
            if i+j+k ==S:
                n=n+same
            else:
                n =n

print(n)


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


K,S = list(map(int, input().split()))
n = 0
up = math.floor(K)
for i in range(0,K+1):
    for j in range(0, K+1):
        if(0<= S-i-j <=K):
            n +=1
        else:
                n =n

print(n)
# 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 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):
    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()))
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 >= 0 and Z <= K):
            ans += 1
print(ans)
# Original solution
k, s  = list(map(int, input().split()))

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):
        for l in range(j, k+1):
            if i + j + l == s:
                if i == j == l:
                    ans1 +=1
                elif i == l or i == j or j == l:
                    ans2 += 1
                else:
                    ans3 += 1
                    

print((ans1+ans2*3+ans3*6))


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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):    
        if 0 <= s-i-j <= k and j <= s-i-j:
            if i == j == s-i-j:
                ans1 +=1
            elif i == s-i-j or i == j or j == s-i-j:
                ans2 += 1
            else:
                ans3 += 1
                    

print((ans1+ans2*3+ans3*6))
#print(ans1, ans2, ans3)
# 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()))
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 i+j<=s and s-(i+j)<=k:
            cnt+=1
print(cnt)
# Original solution
import itertools


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

print((sum([len(set(itertools.permutations(l, 3))) for l in itertools.combinations_with_replacement(list(range(K+1)), 3) if sum(l) == S])))


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

R = 0

for X in range(max(0, S-2*K), K+1):
    for Y in range(max(0, S-X-K), K+1):
        if X + Y <= S:
            R += 1

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

# Optimized solution
k,s=list(map(int,input().split()))
ans=0
for i in range(k+1):
    for j in range(k+1):
        if (s-k<=i+j<=s):
            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):
        if 0 <= s - x - y <= k:
            ans += 1
            # print(x, y, s - x - y)
print(ans)
# Original solution
k,s=list(map(int,input().split(" ")))
c=0
for i in range(k+1):
  for j in range(k+1):
    if i+j>s:
      break
    for l in range(k+1):
      if i+j+l==s:
        c+=1
      if i+j+l>s:
        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):
    if s-i-j<=k and s-i-j>=0:
      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):
            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):
    if 0 <= S-x-y <= K:
        ans += 1
        
print(ans)
# Original solution
K, S = list(map(int, input().split()))
# ok_list = []
cnt = 0
for x in range(K + 1):
    if S - x > K:
        y_max = K + 1
    else:
        y_max = S - x + 1

    for y in range(y_max):
        if S - x - y > K:
            z_max = K + 1
        else:
            z_max = S - x - y + 1
        for z in range(z_max):
            # print((x, y, z))
            if x + y + z == S:
                # print((x, y, z))
                # ok_list.append((x, y, z))
                cnt += 1

print(cnt)

# Optimized solution
K, S = list(map(int, input().split()))
# ok_list = []
cnt = 0
for x in range(K + 1):
    if S - x > K:
        y_max = K + 1
    else:
        y_max = S - x + 1

    if S - x > 2 * K:
        continue
    else:
        # print(y_max, end=" ")
        pass

    for y in range(y_max):

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


# 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()))
count=0
for i in range(0,k+1):
  for j in range(0,k+1):
    for k in range(0,k+1):
      if i+j+k==s:
        count+=1
print(count)

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

count = 0
for i in range(k+1):
    if s-i > k:
        rang = k
    else:
        rang = s-i
    for j in range(rang+1):
        if s-i-j < 0:
            continue
        elif s-i-j > k:
            rangg = k
        else:
            rang = s-i-j
        for h in range(rang+1):
            if i+j+h == 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 or s-i-j < 0:
            continue
        else:
            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):
            if 0 <= s - x - y <=k:
                ans += 1
print(ans)
# Original solution
k, s = list(map(int, input().split()))
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            x = i
            y = j
            z = l
            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
import itertools
K, S = list(map(int, input().split()))
ans = 0
for i in itertools.product(list(range(S+1)), repeat=2):
  if all([j <= K for j in i]):
    Z = S - sum(i)
    if 0 <= Z <= K:
      ans += 1
print(ans)

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

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


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

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



# Optimized solution
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
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 i in range(S + 1):
    X = S - i
    for j in range(i + 1):
        Y = j
        Z = S - X - Y
        if K >= X >= 0 and K >= Y >= 0 and K >= Z >= 0:
            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):
        Z = S - i - j
        if K >= Z >= 0:
            count += 1
print(count)
# Original solution
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
print(c)

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

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