CodeEff/ECCO huggingface dataset:
# 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(0, K + 1):
    for y in range(0, K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count+=1
print(count)
# Original solution
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            for r in range(K+1):
                if(i+j+r == S):
                    ans += 1

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    ans = 0
    ## TLE
    # for i in range(K+1):
    #     for j in range(K+1):
    #         for r in range(K+1):
    #             if(i+j+r == S):
    #                 ans += 1

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

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()
# Original solution
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    ans = 0
    ## TLE
    # for i in range(K+1):
    #     for j in range(K+1):
    #         for r in range(K+1):
    #             if(i+j+r == S):
    #                 ans += 1

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

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(K: int, S: int):
    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S-x-y <= K:
                ans += 1

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()
# Original solution
K,S=[int(i) for i in input().split()]
a=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                a+=1
print(a)

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

    for x in range(0, k):
        for y in range(x+1, k+1):
            if x+y == sz:
                ans +=2
                break
            elif x+y > sz:
                break
print(ans)

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

# 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()))
X = list(range(K + 1))
Y = list(range(K + 1))
Z = list(range(K + 1))
count = 0
for i in X:
    for p in Y:
        for o in Z:
            if (S - (i + p)) > K:
                break
            if (i + p + o) == S:
                count += 1
            elif (i + p + o) > S:
                break
print(count)

# Optimized solution
K, S = list(map(int, input().split()))
X = list(range(K + 1))
Y = list(range(K + 1))
Z = list(range(K + 1))

count = 0

for i in X:
    for p in Y:
        if (S - (i + p)) in Z:
            count += 1

print(count)
# Original solution
K,S = list(map(int,input().split()))
cnt= 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):
                cnt += 1
                if((x + y + z )>S):
                    break

print(cnt)

# Optimized solution
K,S = list(map(int,input().split()))
cnt= 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):
            cnt += 1

print(cnt)
# 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=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=c+1
print(c)
# Original solution
# http://abc051.contest.atcoder.jp/tasks/abc051_b
K,N=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==N:
				count+=1
print(count)

# Optimized solution
# http://abc051.contest.atcoder.jp/tasks/abc051_b
K,N=list(map(int,input().split()))
count=0
for i in range(K+1):
	for j in range(K+1):
		# print i,j,(N-(i+j))
		if 0<=(N-(i+j))<=K:
			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(i, K + 1):
    for k in  range(j, K + 1):
      if i + j + k == S:
        if i == j == k:
          cnt += 1
        elif i == j or j == k or i == k:
          cnt += 3
        else:
          cnt += 6
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 S >= i + j >= S - K:
      cnt += 1
print(cnt)
# Original solution
import sys
input = sys.stdin.readline
 
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 z==S-x-y: count+=1
print(count)

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

# Optimized solution
k,s = list(map(int,input().split()))
Xm = k
Ym = k
Zm = k #使わない
count = 0
for i in range(Xm+1):
  for j in range(Ym+1):
    if 0<= s - (i+j) <= k:
        count += 1
print(count)
# Original solution
import sys
sys.setrecursionlimit(10**6)

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return list(map(int,sys.stdin.readline().rstrip().split()))
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

k,s=mii()

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

# Optimized solution
import sys
sys.setrecursionlimit(10**6)

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return list(map(int,sys.stdin.readline().rstrip().split()))
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

k,s=mii()

cnt=0

for i in range(0,k+1):
    for j in range(0,k+1):
        if 0<=s-(i+j)<=k:
            cnt+=1
print(cnt)
# Original solution
from sys import stdin
K,S = [int(x) for x in stdin.readline().rstrip().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
from sys import stdin
K,S = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for X in range(0,K+1):
    for Y in range(0,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):
  if(i>s):
    break
  for j in range(k+1):
    if(i+j>s):
      break
    for c in range(k+1):
      if(i + j + c == 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 and s-i-j <= k):
      count += 1
print(count)
# Original solution
a = list(map(int,input().split()))
k = int(a[0])
s = int(a[1])
count = 0

for x in range(k+1):
    if (x == s):
       count += 1
    else: 
        for y in range(k+1):
             if (x + y == s):
                 count += 1
             else:
                for z in range(k+1):
                    if(x + y + z == s):
                        count += 1

print(count)

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

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

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

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

for i in range(K+1):
    for j in range(K+1):
            if 0 <= S - (i + j) <= K:
                res += 1
                
print(res)
# Original solution
def solve(K, S):
    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)

if __name__ == '__main__':
    K, S = list(map(int, input().split()))
    solve(K, S)

# Optimized solution
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
                if K >= S - (x + y) >= 0 :
                    count += 1
                    
    print(count)

if __name__ == '__main__':
    K, S = list(map(int, input().split()))
    solve(K, S)
# 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 and S - i - j <= 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):
        if 0<=s-x-y and s-x-y<=k:
            count+=1

print(count)
# Original solution
K,S=input().split()
K,S=[int(K),int(S)]
a=0
for X in range(K+1):
    for Y in range(K+1):
        Z=S-X-Y
        if 0<=Z<=K and X+Y+Z==S:
           a+=1 
print(a)

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

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

if __name__ == '__main__':
    main()
# Original solution
K, S = list(map(int, input().split()))

# print(K)
# print(S)

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()))

# print(K)
# print(S)

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

print(count)
# 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(i+j<=s and s-(i+j)<=k):
        ans+=1
print(ans)
# Original solution
def resolve():
    import bisect
    k, s = list(map(int, input().split()))
    cnt = 0
    k += 1
    lx = [x for x in range(k)]
    for i in range(k):
        for j in range(k):
            if s-i-j >= 0:
                index = bisect.bisect_right(lx, s-i-j)-1
                if i+j+index == s and index <= k:
                    cnt += 1
    print(cnt)
resolve()

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

XYZ = [[z,y,x] for z in range(0,K+1) for y in range(0,K+1) for x in range(0,K+1) if (x+y+z)==S]

print((len(XYZ)))


# Optimized solution
k,s = list(map(int, input().split()))
a = (s+2)*(s+1)/2
b = (s-k+1)*(s-k)/2
c = (s-2*k)*(s-2*k-1)/2
 
if s <= k:
    print((int(a)))
elif s <= 2*k+1:
    print((int(a-3*b)))
elif s <= 3*k:
    print((int(a-3*b+3*c)))
# Original solution
n,s = list(map(int, input().split()))
cnt = 0
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if 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):
        z = s - i - j
        if z >= 0 and z <= k:
            cnt+=1
print(cnt)
# 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 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):
    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
z=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
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()))

li = []
for x in range(K+1):
    for y in range(K+1):
        if S-x-y >= 0 and S-x-y <= K:
            li.append([x, y, S-x-y])
print((len(li)))

# 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-x-y >= 0 and S-x-y <= K:
            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 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 0<=S-i-j<=K:
          ans+=1
print(ans)
# Original solution
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
k, s = na()

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
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
k, s = na()

count = 0
for x in range(k+1):
  for y in range(k+1):
      if s-x-y >= 0 and s-x-y <= k:
        count += 1
print(count)
# Original solution
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(k,s):
  res = 0
  for i in range(k+1):
    for j in range(k+1):
      for l in range(k+1):
        if i+j+l == s:
          res += 1

  return res



def main():
  K,S = list(map(int,input().split()))
  # a = list(map(int,input().split()))
  print((solve(K,S)))
  return

if __name__ == '__main__':
  main()


# Optimized solution
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(k,s):
  res = 0
  for i in range(k+1):
    for j in range(k+1):
      l = s - i - j
      if 0 <= l <= k:
        res += 1

  return res



def main():
  K,S = list(map(int,input().split()))
  # a = list(map(int,input().split()))
  print((solve(K,S)))
  return

if __name__ == '__main__':
  main()
# Original solution
"""
AtCoder Beginner Contest 051
B - Sum of Three Integers
"""

if __name__ == "__main__":
    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 or S - (x + y) > K:
                continue
            ans += 1

    print(ans)


# Optimized solution
"""
AtCoder Beginner Contest 051
B - Sum of Three Integers
"""

if __name__ == "__main__":
    K, S = list(map(int, input().split()))

    ans = 0
    A = [i for i in range(K+1)]
    for x in A:
        for y in A:
            if x + y > S or S - (x + y) > K:
                continue
            ans += 1

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

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

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
sys.setrecursionlimit(10**6)
##############################

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


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

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

true=0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                true=true+1

print(true)

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

true=0

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

print(true)