CodeEff/ECCO huggingface dataset:
# Original solution
k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(i + 1):
        for l in range(j + 1):
            if i + j + l == s:
                if i == j == l:
                    ans += 1
                elif i == j or j == l or l == i:
                    ans += 3
                else:
                    ans += 6
print(ans)


# Optimized solution
k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(i + 1):
        l = s - (i + j)
        if 0 <= l <= k and l <= j <= i:
            if i == j == l:
                ans += 1
            elif i == j or j == l or l == i:
                ans += 3
            else:
                ans += 6
print(ans)
# Original solution
K, S = list(map(int, input().split()))
re = 0
for x in range(K+1):
    for y in range(K+1):
        z = min(K, max(0, S-x-y))
        if x + y + z == S:
            re += 1
print(re)

# Optimized solution
K, S = list(map(int, input().split()))
re = 0
for x in range(min(S+1, K+1)):
    for y in range(min(S+1-x, K+1)):
        if S - x - y <= K:
            re += 1
print(re)
# 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):
        z = S - i - j
        if 0 <= z <= K:
            cnt += 1

print(cnt)
# 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(x, K+1):
        for z in range(y, K+1):
            if x + y + z == S:
                if x == y and y == z:
                    count += 1
                elif x == y or y == z or z == x:
                    count += 3
                else:
                    count += 6
                break
print(count)


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


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

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

for x in range(a+1):
  for y in range(a+1):
    for z in range(a+1):
      if x + y + z == b:
        ans += 1

print(ans)

# Optimized solution
a, b = list(map(int, input().split()))
ans = 0

for x in range(a+1):
  for y in range(a+1):
    z = b - x - y
    
    if z >= 0 and a >= z:
      ans += 1

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

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

maximum, equal = list(map(int, input().split()))
counter = 0

for i in range(maximum + 1):
    for j in range(maximum + 1):
        for k in range(maximum + 1):
            if equal == i + j + k:
                counter += 1

print(counter)


# Optimized solution
# coding: utf-8
# Your code here!

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

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

cnt = 0

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


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

cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z <= 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 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 z>=0 and z<=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):
    for k in range(K+1):
      if int(i + j + k) == 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 and z <= K: ans += 1
print(ans)
# Original solution
# coding: utf-8
input_lines=input().split()
K = int(input_lines[0])
S = int(input_lines[1])
M=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:
          M+=1
        elif i==j or j==k:
          M+=3
        else:
          M+=6
print(M)

# Optimized solution
# coding: utf-8
input_lines=input().split()
K = int(input_lines[0])
S = int(input_lines[1])
M=0
for i in range(K+1):
  for j in range(i,K+1):
    k =S-i-j
    if i<=j<=k<=K:
      if i==j==k:
        M+=1
      elif i==j or j==k:
        M+=3
      else:
        M+=6
print(M)
# Original solution
import itertools
import math

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

ans = 0
for i in itertools.combinations_with_replacement(list(range(k+1)), 3):
    if sum(i) == s:
        n_unique = len(set(i))
        if n_unique == 1:
            ans += 1
        elif n_unique == 2:
            ans += 3
        elif n_unique == 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 (z >= 0) and (z <= k):
            ans += 1

print(ans)
# Original 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)

# 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 i in range(k, -1,-1):
        for j in range(k, -1,-1):
                z = s - i - j
                if i + j + z == s and k >= z and z >= 0:
                        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):
                if 0 <= s-i-j <= k:
                        count += 1
print(count)
# 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):
                z = s - x - y
                #print("{} {} {}".format(x, y, z))
                if  0 <= z <= k and x + y + z == s:
                        count += 1
print(count)

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

l = []
for i in range(k+1):
    for j in range(k+1):
        l.append([i,j])
#print(len(l))

q = 0
for r in range(k+1):
    for p in range(len(l)):
        if r + sum(l[p]) == s:
                q += 1

#print(k,s,l)
print(q)


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

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        m = s - i - j
        if 0 <= m <= k:
            comb = [i, j, m]
            sum_set.append(comb)
        else:
            continue
print((len(sum_set)))


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

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

# Optimized solution
k,s = list(map(int, input().split()))
cnt=0
minX=max(s-2*k, 0)
maxX=min(s, k)
for x in range(minX, maxX+1):
    rest=s-x
    if k>=rest:
        cnt+=rest+1
    else:
        cnt+=2*k-rest+1
    
print(cnt)
# Original solution
a,b=list(map(int,input().split()))
print(([_+y+z for _ in range(a+1) for y in range(a+1) for z in range(a+1)].count(b)))



# 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-y-z<=k])))
# Original solution
K,S=list(map(int,input().split()))
ans=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:
          ans+=6
        elif i<j==k or  i==j<k:
          ans+=3
        else:
          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):
    k=S-(i+j)
    if 0<=k<=K:
      ans+=1
print(ans)
# Original solution
import itertools

K, S = list(map(int, input().split()))
num = list(range(K+1))
count = 0

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


cnt = 0

if S <= K:
    for x in range(S+1):
        for y in range(S+1):
            for z in range(S+1):
                if x + y + z == S:
                    cnt += 1
else :
    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 = [int(i) for i in 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

import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(s-x+1):
        z = s-x-y
        ans = x+y+z
        if ans==s and y <= k and z <= k:
            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(min(k+1, s-x+1)):
        z = s-x-y
        ans = x+y+z
        if y <= k 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):
        if S-x-y >= 0 and K >= S-x-y:
            count += 1
            
print(count)
# Original solution
k, s = list(map(int, input().split()))

l = set()
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s and s-i-j >= 0:
            l.add((i, j, s-i-j))
        else:
            continue

print((len(l)))

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

count = 0
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s and s-i-j >= 0:
            count += 1
        else:
            continue

print(count)
# Original solution
k, s = list(map(int, input().split()))
counter = 0
for x in range(k + 1):
    for y in range(x, k + 1):
        z = s - x - y
        if y <= z <= k:
            if x == y == z:
                counter += 1
            elif x == y or y == z:
                counter += 3
            else:
                counter += 6

print(counter)


# Optimized solution
k, s = list(map(int, input().split()))
counter = 0
for i in range(k + 1):
    counter += max(min(k, s - i) - max(0, s - k - i) + 1, 0)

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 X + Y + Z == S:
        count += 1
print(count)

# Optimized solution
K, S = list(map(int,input().split()))
count = 0
#ZはXとYが決まった時点で自動的に決まる。
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y 
#範囲が条件ないならOK
    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):
    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):
                count = count + 1
print(count)

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

ans = 0
for i in range(x+1):
  x1 = S-i
  for j in range((K if x1>K else x1)+1):
    x2 = S-i-j
    for k in range((K if x2>K else x2)+1):
      if i+j+k==S:
        #print("{} {} {}".format(i,j,k))
        ans += 1
print(ans)

# Optimized solution
K, S = list(map(int, input().split()))
x = S if K>S else K

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

print(ans)

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

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

                break

print(result)


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

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

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

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

print(result)


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

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

print(result)
# Original solution
K,S = list(map(int,input().split()))
counter = 0
counter_d = 0
counter_tri =0
for i in range(K+1):
    for j in range(i+1,K+1):
        for k in range(j+1,K+1):
            if i+j+k ==S:
                counter +=6
for i in range(K+1):
    for k in range(K+1):
       if 2*i+k== S:
           if i == k:
               counter += 1
           else:
               counter +=3
print(counter)


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

for x in range(a+1):
  for y in range(a+1):
    for z in range(a+1):
      
      if x+y+z==b:
        n+=1
print(n)
      
   

# Optimized solution
a,b=list(map(int,input().split()))
n=0

for y in range(a+1):
  for z in range(a+1):
      p=b-y-z
      if 0<=p and p<=a:
        n+=1
print(n)
# 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 S-x-y >= 0 and S-x-y <= 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

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()));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 = 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()))
a=[];ans=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):a.append((i,j,k))
for i in a: ans+=1 if sum(i)==S else 0
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):
        for k in range(K+1):ans+=1 if i+j+k==S else 0
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 k in range(K+1):ans+=1 if i+j+k==S else 0
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 0<=S-i-j: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 S-i-j<=K and 0<=S-i-j:ans+=1
print(ans)

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

# Optimized solution
a,b = list(map(int,input().split()))
c = 0
for i in range(a+1):
    for j in range(a+1):
        z = b-i-j
        if i+j+z==b and 0<=z<=a:
            c+=1
print(c)
# Original solution
def actual(K, S):
    my_range = lambda n: list(range(n + 1))

    count = 0

    for x in my_range(K):
        for y in my_range(K):
            for z in my_range(K):
                if x + y + z == S:
                    count += 1

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

print((actual(K, S)))

# Optimized solution
def actual(K, S):
    my_range = lambda n: list(range(n + 1))

    count = 0

    for x in my_range(K):
        for y in my_range(K):
            z = S - (x + y)
            if 0 <= z <= K:
                count += 1
    return count

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

print((actual(K, S)))
# Original solution
k, s = list(map(int, input().split()))
count = 0
for l in range(k+1):
  for m in range(k+1):
    for n in range(k+1):
      if l+m+n == 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
# B
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
# B
k, s = list(map(int, input().split()))

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

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