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

result = 0

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

print(result)

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

result = 0

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

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

print(ans)

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

print(ans)
# Original solution
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    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)
    return


# Generated by 1.1.7.1 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):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                count += 1
    print(count)
    return


# Generated by 1.1.7.1 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
import itertools

a,b=(int(x) for x in input().split())
l = list(range(a+1))
count = 0
m = [0 for x,y,z in itertools.product(l,l,l)if (x+y+z) == b]
#m = [0 for x in l for y in l for z in l if (x+y+z) == b]
print((len(m)))

# Optimized solution
import itertools
a,b=(int(x) for x in input().split())
l = list(range(a+1))
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    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 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)
# Original solution
K, S = list(map(int, input().split()))

# S-K<=X+Y<=S を満たすX,Yの組の数が答え
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if S-K <= X+Y <= S:
            ans += 1

print(ans)

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

# 各ケースごとに格子点の個数を求める
if 0 <= S <= K:
    print((int((S+1)*(S+2)/2)))
elif K < S <= 2*K:
    print((int((K+1)**2 - (2*K-S)*(2*K-S+1)/2 - (S-K)*(S-K+1)/2)))
else:
    print((int((3*K-S+1)*(3*K-S+2)/2)))
# 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):
            ans += ((x + y + z) == S)
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
        ans += ((0<=z<=K))
print(ans)
# Original solution
K, S = list(map(int,input().split()))

if(3*K == S):
  print((1))
  exit()
cnt = 0
for i in range(K+1):
  for j in range(K+2):
    for k in range(K+3):
      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(S-(i+j) <= K and S-(i+j) >= 0):
      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):
    if(S-(i+j) <= K and S-(i+j) >= 0):
      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+1):
      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):
    if(0 <= S-i-j < K+1):
      cnt += 1
print(cnt)

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

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

cnt = 0
for i in range(K+1):
  for j in range(K+1):
    if(0 <= S-i-j < K+1):
      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()))
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 i in range(k+1):
    for l in range(k+1):
        if (s-i-l) >= 0 and (s-i-l) <= k:
            if i+l+(s-i-l) == s:
                ans += 1
print(ans)

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

from itertools import combinations_with_replacement

cwr = combinations_with_replacement(list(range(0, k + 1)), 3)
ans = 0

for x, y, z in cwr:
    if x + y + z == s:
        st = set([x, y, z])
        if len(st) == 1:
            ans += 1
        elif len(st) == 2:
            ans += 3
        else: #len(st) == 3
            ans += 6

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

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


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

num = 0
for x in range(K+1):
    for y in range(K+1):
#        for z in range(K+1):
#            if x + y + z == S:
        if 0 <= S - x- y <= K:
            num += 1
                
print(num)
# Original solution
#https://atcoder.jp/contests/abc051/tasks/abc051_b
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
#https://atcoder.jp/contests/abc051/tasks/abc051_b
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()))

kouho_list = []

for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):
			tmp_sum = x + y + z
			if tmp_sum == s:
				kouho_list.append(tmp_sum)

print((len(kouho_list)))

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

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

# Optimized solution
k,s = list(map(int,input().split()))
r=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            r+=1
print(r)
# Original solution
# coding: utf-8
import time
import re
import math
import fractions

def main():
    K,S=list(map(int,input().split()))
    count=0
    for x in range(0,K+1):
        for y in range(0,K+1):
            if(x+y>S):break
            if S-x-y<=K and S-x-y>=0:
                count+=1
    print(count)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())



# Optimized solution
# coding: utf-8
import time
import re
import math
import fractions

def main():
    K,S=list(map(int,input().split()))
    count=0
    for x in range(0,K+1):
        for y in range(0,K+1):
            if S-x-y<=K and S-x-y>=0:
                count+=1
    print(count)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# 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):
            # print(x, y, z)
            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):
        ans += 1 if 0 <= S - x - y <= K else 0
print(ans)
# Original solution
k, s = [int(n) for n in 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 = [int(n) for n in 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()))
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
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()))

x =0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                x +=1

print(x)

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

x =0

for i in range(min(k+1,s+1)):
    x += max(0, min(s-i,k)+1 - max(0,s-i-k) )

print(x)
# Original solution
k,s = [int(x) for x in 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 = [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)
# Original solution
k, s = list(map(int, input().split()))
ks = [_ for _ in range(k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        for ksk3 in ks:
            if s == ksk1 + ksk2 + ksk3:
                count += 1
            
print(count)

# Optimized solution
k, s = list(map(int, input().split()))
ks = [_ for _ in range(k+1)]

count = 0

for ksk1 in ks:
    for ksk2 in ks:
        z = s - ksk1 - ksk2
        if 0 <= z <= k:
            count += 1
            
print(count)
# Original solution
a,b=list(map(int,input().split()))
ans=0
for i in range(a+1):
  for j in range(a+1):
    for k in range(a+1):
      if i+j+k==b:
        ans+=1
print(ans)

# Optimized solution
a,b=list(map(int,input().split()))
ans=0
for i in range(a+1):
  for j in range(a+1):
      if 0<=b-i-j<=a:
        ans+=1
print(ans)
# Original solution
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):
        m = s - i - j
        if (0 <= m <= k):
            ans += 1

print(ans)
# Original solution
# -*- coding: utf-8 -*-
# input
k, s = list(map(int, input().split()))
# calc
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
# output
print(ans)

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

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)

# Optimized solution
# coding = SJIS
k, s = list(map(int, input().split()))
if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    ans = ((k + 1) * (k + 2) / 2) - ((2 * k - s) * ((2 * k - s) + 1) / 2) + (t * (2 * k - ((2 * k - s) - 1)) / 2)
elif s <= 3 * k:
    ans = (3 * k - s + 1) * ((3 * k - s + 1) + 1) / 2
print((int(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 x+y<=S:
			if 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):
        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+1:
                cnt +=1

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


print(count)

# Optimized solution
K,S = (int(x) for x in input().split())
count = 0

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


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

print(cnt)

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

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

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


# Optimized solution
K,S = list(map(int, input().split()))
count = 0
# 計算量大きすぎる
# for x in range(K+1):
#     for y in range(K+1):
#         for z in range(K+1):
#             if x+y+z == S:
#                 count += 1

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

counter = 0

for x in range(k+1):
    if s-x > 2 * k:
        continue
    for y in range(k+1):
        if s-x-y > k:
            continue
        elif s-x-y <= k and s-x-y >=0:
            counter += 1
                
print(counter)

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

for x in range(k+1):
    if s-x > 2*k:
        continue
    for y in range(k+1):
        if s-x-y > k or s-x-y < 0:
            continue
        else:
            counter += 1
            
print(counter)
# 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 S == x+y+z:
                count += 1

print(count)


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

for x in range(K+1):
    for y in range(K+1):
        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):
    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)
    return


# Generated by 1.1.6 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):
    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 += 1
    print(cnt)
    return


# Generated by 1.1.6 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
k, s = list(map(int, input().split()))

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

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

pat = 0
for x in range(k+1):
    for y in range(k+1):
            if 0 <= s - (x + y) <= k:
                pat += 1
print(pat)
# 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 S-x-y>=0 and S-x-y<=K:
            c+=1
        """
        for z in range(K+1):
            if x+y+z==S:
                c+=1
        """
print(c)
# Original solution
k,s=list(map(int,input().split()))
cnt=0
for i in range(k+1):
  for j in range(k+1):
    for h in range(k+1):
      if s==i+j+h:
        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):
    h = s-i-j
    if 0<=h and h <=k:
      cnt+=1
print(cnt)
# 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):
      total = i +j + k
      if total == 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) :
    k = S - i - j
    if k >= 0 and k <= K :
      num += 1
print(num)
# Original solution
k, s = list(map(int, input().split()))

res = 0
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:
                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 x + y <= s:
            if x + y + k >= s:
                res += 1
        else:
            break

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

counter = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if S == x + y + z:
                counter += 1
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 0 <= z and z <= K:
            counter += 1
print(counter)
# Original solution
k,s=list(map(int,input().split()))
cnt=0
for x in range(max(0,s-2*k),k+1):
  if x>s:
    break
  for y in range(max(0,s-2*k),k+1):
    if x+y>s:
      break
    if s-(x+y)>=0 and s-(x+y)<=k:
      cnt+=1
print(cnt)


# Optimized solution
k,s=list(map(int,input().split()))
cnt=0
for x in range(k+1):
  if s-x<0:
    break
  elif s-x<=k:
    cnt+=(s-x)+1
  elif s-x>2*k:
    cnt+=0
  elif s-x>k:
    cnt+=2*k-(s-x)+1
print(cnt)
# Original solution
K, S = list(map(int, input().split()))
count = 0
for i in range(K+1):
  if i <= S:
    for j in range(K+1):
      if j <= S:
        if S - i - j <= K and S - i - j >= 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):
        if S - i - j <= K and S - i - j >= 0:
          count += 1        
print(count)
# 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):
            ty = i + j + k
            if ( ty == 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 + 1):
            count += 1
print(count)