CodeEff/ECCO huggingface dataset:
# 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):
        if k>=s-(y+x)>=0:
            count+=1
print(count)
# Original solution

def solve(K, S):
    import bisect
    count = 0
    z_array = [i for i in range(K+1)]
    for x in range(K+1):
        for y in range(K+1):
                z = S - x - y
                index = bisect.bisect_left(z_array, z)
                if(index != K+1 and z_array[index] == z):count+=1
    return count

def main():
    K, S = list(map(int, input().split()))
    print((solve(K, S)))
#print(solve(2, 2))
#print(solve(5, 15))
main()

# Optimized solution

def solve(K, S):
    import bisect
    count = 0
    z_array = [i for i in range(K+1)]
    for x in range(K+1):
        for y in range(K+1):
                z = S - x - y
                if(z >= 0 and z <= K):count+=1
    return count

def main():
    K, S = list(map(int, input().split()))
    print((solve(K, S)))
#print(solve(2, 2))
#print(solve(5, 15))
main()
# Original solution
import sys
input = sys.stdin.readline
K,S=list(map(int,input().split()))
crt=0
for x in range(0,K+1):
  for y in range(0,K+1):
    z=S-x-y
    if 0<=z<=K:
      crt+=1
print(crt)

# Optimized solution
K,S=list(map(int,input().split()))
crt=0
for x in range(0,K+1):
  for y in range(0,K+1):
    z=S-x-y
    if 0<=z<=K:
      crt+=1
print(crt)
# Original solution
k, s = list(map(int, input().split()))
ans = 0
for l in range(k+1):
  for n in range(k+1):
    for m in range(k+1):
      if l+n+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):
        if 0 <= s-i-j <= 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:
            cnt += 1
print(cnt)
# Original solution
k,s=list(map(int,input().split()));k+=1;print((sum(k>s-I//k-I%k>=0for I in range(k*k))))

# Optimized solution
k,s=list(map(int,input().split()));print((sum(max(0,min(2*k+i-s+1,s-i+1))for i in range(k+1))))
# 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 0 <= z <= K:
            ans += 1
print(ans)
# Original solution
k,s = (int(i) for i in input().split())
answer = 0
for i in range(((s-s%3)//3)+1):
	n = s-i
	for i2 in range(i,((n-n%2)//2)+1):
		for i3 in range(i2,k+1):
			if i+i2+i3==s:
				if i==i2 and i2==i3: answer += 1
				elif i==i2 or i2==i3: answer += 3
				else: answer += 6
				break
print(answer)

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

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

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

# Optimized solution
k,s=list(map(int,input().split()))
print(([x+y+s-(x+y) for x in range(k+1) for y in range(k+1) if 0<= s-x-y <= k].count(s)))
# Original solution
K,S=list(map(int,input().split()))
A=[]

for i in range(K+1) :
    for j in range(K+1) :
        if S-i-j>K or S-i-j<0 :
             continue
        A.append([i,j,S-i-j])

print((len(A)))

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

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


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

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

L=list(itertools.combinations_with_replacement(A,3))
SUM=0
for i in range(len(L)):
    if L[i][0]+L[i][1]+L[i][2]==S:
        if len(L[i]) == len(set(L[i])) + 2:
            SUM = SUM + 1  # sonomama! 3tu tyouhuku
        if len(L[i]) == len(set(L[i])) + 1:
            SUM = SUM + 3  # kakeru3 2tu tyouhuku
        if len(L[i]) == len(set(L[i])):  # kakeru6 tyouhuku 0
            SUM = SUM + 6

print(SUM)

# Optimized solution
K,S=list(map(int,input().split()))
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(b)
# 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):
            sumn = x + y + z
            if sumn == 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):
        sumn = S - (x + y)
        if sumn >= 0 and sumn <= 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):
        sumn = S - (x + y)
        if sumn >= 0 and sumn <= 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):
        z = S - x - y
        if 0 <= z <= K:
            count += 1

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


# Optimized solution
K,S = list(map(int,input().split()))
count = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i -j
        if 0<= k <= 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 s == x + y + z:
              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 and z <= k:
            ans += 1
print(ans)
# Original solution
# B - Sum of Three Integers
def main():
    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
    else:
        print(cnt)



if __name__ ==  "__main__":
    main()

# Optimized solution
# B - Sum of Three Integers
def main():
    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 0 <= z <= k:
                cnt += 1
    else:
        print(cnt)



if __name__ ==  "__main__":
    main()
# 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()))
n = k + 1
count = 0
for i in range(n):
    for j in range(n):
        for l in range(n):
            if i + j + l == s:
                count += 1
print(count)

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

# Optimized solution
k,s = list(map(int,input().split()))
print((sum(0<=s-i-j<=k for i in range(k+1) for j in range(k+1))))
# Original solution
a = list(map(int,input().split()))
num=0
for l in range(a[0]+1):
    for m in range(a[0]+1):
        if(a[1]-l-m <= a[0] and a[1]-l-m >= 0):
            num+=1
print(num)

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

count = 0
for i in range(0,K+1):
    if i > S:
        continue
    for j in  range(0,K+1):
        if i + j > S:
            continue
        for k in  range(0,K+1):
            if i + j + k > S:
                continue
            if i + j + k == S:
                count += 1
print(count)

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

count = 0
for i in range(0,K+1):
    if i > S:
        continue
    for j in  range(0,K+1):
        if 0 <= (S - i - j) <= 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 and 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:
            continue
        if 0 <= s-x-y <= k:
            ans += 1

print(ans)
# Original solution
k, s = list(map(int, input().split()))
ans = 0
for a in range(k+1):
    if a > s:
        break
    for b in range(k+1):
        if a + b > s:
            break
        for c in range(k+1):
            if a + b + c == s:
                ans += 1
            elif a + b + c > s:
                break
print(ans)

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

Z1 = [i for i in range(K+1)]

for i in range(K+1):# X
  for j in range(K+1):#Y
    Z = S - i - j
    if Z in Z1:
      count += 1

print(count)

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

count= 0

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

count= 0

for i in range(K+1):# X
  for j in range(K+1):#Y
    Z = S - i - j
    if 0 <= Z <= K:
      count += 1
      #print(i,j,Z)
print(count)

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

c = itertools.product(sa,repeat=3)

for i in c:
  if i[0] + i[1] + i[2] == 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 0 <= z <= k:
      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):
        if i + j > s:
            break
        elif 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):
        if 0 <= s - i - j <= k:
            cnt += 1
print(cnt)
# Original solution
def slove():
    import sys
    input = sys.stdin.readline
    k, s = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(k + 1):
        for j in range(k + 1):
            n = s - i - j
            if 0 <= n <= k:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    k, s = list(map(int, readline().split()))
    cnt = 0
    for x in range(k + 1):
        for y in range(k + 1):
            ts = s - x - y
            if 0 <= ts <= k:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()
# Original solution
k,s = list(map(int, input().split()))
cnd = list(range(0, k+1))
print((str(sum([1 for x in cnd for y in cnd for z in cnd if x+y+z == s]))))

# Optimized solution
k,s = list(map(int, input().split()))
cnd = list(range(0, k+1))
print((str(sum([1 for x in cnd for y in cnd if s-x-y in cnd]))))
# Original solution
# -*- coding: utf-8 -*-
K,S=list(map(int,input().split()))
count=0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i+j+k==S:
        count=count+1
print(count)

# Optimized solution
# -*- coding: utf-8 -*-
K,S=list(map(int,input().split()))
count=0
for i in range(K+1):
  for j in range(K+1):
    k=S-i-j
    if 0<=k<=K:
      count=count+1
print(count)
# Original solution
K,S = list(map(int,input().split()))

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

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

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

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()))
n = 0

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

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

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

print(n)

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

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

for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y<=K:
      a+=1

print(a)
# Original solution
#-*-coding:utf-8-*-

def main():
    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)

if __name__ == '__main__':
    main()

# Optimized solution
#-*-coding:utf-8-*-

def main():
    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)

if __name__ == '__main__':
    main()
# 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(min(S-x, K)+1):
    if S-x-y <= K: 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):
    if s-i-j >= 0 and 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):
  if s-i>2*K:
    continue
  for j in range(K+1):
    if s-i-j<0:
      break
    if s-i-j<=K:
      cnt+=1
print(cnt)
# Original solution
K,S = list(map(int, input().split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    z = S-x-y
    if 0 <= z <= K:
      count += 1
print(count)

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

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

for x in range(K+1):
    rem = S - x
    if rem < 0: break
    if rem > 2*K: continue
    for y in range(K+1):
        z = rem - y
        if z < 0: break
        if z > K: continue
        ans += 1
print(ans)


# Optimized solution
K,S = list(map(int,input().split()))
ans = 0
for a in range(K+1):
    if a > S: break
    for b in range(K+1):
        c = S-a-b
        if 0 <= c <= 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):
        z = S - i - j
        if 0 <= z <= K:
            count += 1

print(count)

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

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

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

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

print(cnt)

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

if __name__ == "__main__":
    main()
# Original 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 <= K:
            counter += 1
print(counter)


# Optimized solution
K, S = list(map(int, input().split()))
ans = 0
for x in range(K+1):
    for y in range(min(K, S-x)+1):
        z = S - x - y
        if K >= z >= 0:
            ans += 1
print(ans)
# Original solution
def main():
    k, s = list(map(int, input().split()))
    ans = 0
    for x in range(max(0, s-2*k), k + 1):
        for y in range(max(0, s-2*k), k + 1):
            for z in range(k + 1):
                if x + y + z == s:
                    ans += 1
                    break
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    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)


if __name__ == '__main__':
    main()
# 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
K, S = list(map(int, input().split()))

ans = 0
for x in range(K + 1):
    for y in range(x, K + 1):
        z = S - (x + y)
        if y <= z and z <= K:
            if x == y and y == z:
                ans += 1
            elif x == y or y == z or z == x:
                ans += 3
            else:
                ans += 6

print(ans)
# 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 == z:
                    count += 1
                elif x != y and y != z and z != x:
                    count += 6
                else:
                    count += 3
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 s-k <= x + y <= s:
            count += 1
print(count)
# Original solution
K, S = list(map(int, input().split()))

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    if S - (x + y) <= K:
      z = S - (x + y)
      if z >= 0 and z <= K:
        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 z >= 0 and z <= K:
      counter += 1

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