peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
input = sys.stdin.readline

def main():
    k, s = 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
            if s - (x + y) <= k:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()
K,S = map(int,input().split())
ret =0
for X in range(K+1):
  for Y in range(K+1):
    if 0 <= S-X-Y and S-X-Y <=K:
      ret +=1
print(ret)
k,s = map(int,input().split())
print(sum(0<=s-i-j<=k for i in range(k+1) for j in range(k+1)))
K,S=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)
K, S = list(map(lambda n: int(n), input().split(" ")))
cnt = 0
# X + Y + Z = S, 0 <= X, Y, Z <= K #
for x in range(K + 1):
  if S - x > 2 * K:
    continue
  for y in range(K + 1):
    if 0 <= S - x - y <= K:
      cnt += 1

print(cnt)
K, S = 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)
import sys


input = sys.stdin.readline
k, s = map(int, input().split())

# min_num = s - k * 2
# if min_num <= 0:
min_num = 0

ans = 0

for x in range(min_num, k + 1):
    for y in range(min_num, k + 1):
        z = s - x - y
        if z > k or z < 0:
            continue
        else:
            ans += 1

print(ans)
k, s = 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)
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        if 0 <= S-(i+j)<=K:
            ans += 1
print(ans)
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        if S <= (i+j+K) and i+j<=S:
            count += 1
            
print(count)
K,S=map(int,input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y and S-X-Y<=K:
      cnt+=1
print(cnt)
K, S = map(int, input().split())

ans = 0

for i in range(0,K+1):
    for j in range (0,K+1):
        if (S-K) <= (i + j) <= S:
            ans = ans + 1
            continue
print(ans)
#!/usr/bin/env python3

K, S = map(int, input().split())
AB = []
ret = 0
for i in range(K+1):
    for j in range(K+1):
        AB.append(i+j)

for i in range(len(AB)):
    if 0 <= S - AB[i] <= K:
        ret += 1

print(ret)
k, s = map(int,input().split())

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

print(ans)
k, s = map(int, input().split())
p = 0
for x in range(0,k+1):
  for y in range(0,k+1):
    z = s - x - y
    if z >= 0 and z <= k:
      p += 1
print(p)
k,s=list(map(int,input().split()))
ans=0
for i in range(k+1):
    for j in range(k+1):
        if -1 < s-i-j < k+1:
            ans+=1
print(ans)
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if s <= i+j+k and i+j <= s:
            ans += 1
print(ans)
K, S = 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)
k,s=map(int, input().split())
Ans = 0
for i in range(k+1):
    for j in range(k+1):
        x = i
        y = j
        z = s - i - j
        if z <= k and z >= 0:
            Ans += 1
print(Ans)
k , s = map(int , input().split())
ans=0
for i in range(0 , k+1):
	for j in range(0 , k+1):
		if i+j<=s and (s-(i+j))<=k:
			ans =ans+1
print(ans)
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
ans = []

if S > K:
   z = list(range(K+1))
else:
  z = list(range(S+1))
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))
k,s = 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)
k, s = map(int, input().split())

from itertools import product

k_list = list(range(k+1))
count = 0
for x, y in product(k_list, k_list):
  # print(x, y, s-x-y)
  if 0<=s-x-y<=k:
    count+=1
print(count)
import sys

def solve():
    input = sys.stdin.readline
    K, S = 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)

    return 0

if __name__ == "__main__":
    solve()
# -*- coding: utf-8 -*-
                   
K, S = 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)
K,S=[int(x) for x in input().rstrip().split()]
cnt=0
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-(x+y) and S-(x+y)<=K:
      cnt+=1
print(cnt)
k,s = map(int, input().split())

l = 0

if s <= k:
  l = int((s+2)*(s+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)
k, S = 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)
k,s = 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=cnt+1
        else:
            continue
    
print(cnt)
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 and z<=K:
            count += 1
print(count)
k, s = map(int, input().split())
ans = 0
tmp = 0

for i in range(k + 1):
    x = i
    tmp = s - x

    if tmp < 0:
        break

    if 2 * k >= tmp:
        if k >= tmp:
            ans = ans + tmp + 1
        else:
            ans = ans + ((k + 1) - (tmp - k))

print(ans)
k, s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        if i + j > s:
            break
        m = s - i - j
        if m <= k:
            count += 1
print(count)
K, S = 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)
#!/usr/bin/env python
# coding: utf-8

# In[4]:


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


# In[6]:


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


# In[ ]:
import sys
input = sys.stdin.readline
from itertools import combinations

def main():
    k, s = map(int, input().split())
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                yield 1

print(sum(main()))
k, s = map(int, input().split())
c = 0
for i_x in range(k+1):
    for i_y in range(k+1):
        z = s - (i_x + i_y)
        if z >= 0 and z <= k:
            c += 1
print(c)
K,S=map(int,input().split()) 
print(len([True for x in range(K+1) for y in range(K+1) if (S-x-y>=0) and (S-x-y<=K)]))
k, s = map(int, input().split())

ans = 0
for q in range(k + 1):
    for w in range(k + 1):
        if 0 <= (s - q - w) <= k:
            ans += 1
print(ans)
k, s = map(int, input().split())
res = 0

for x in range(k+1):
  for y in range(k+1):
    z = s - (x + y)
    if z >= 0 and z <= k:
      res += 1
        
print(res)
# -*- coding: utf-8 -*-
import sys

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

counter = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            # print(i, j , s - i - j)
            counter += 1

print(counter)
k,s = 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)
K, S = tuple(map(int, input().split()))


cnt = 0
for a in range(K+1):
    for b in range(K+1):
        c = S - (a + b)
        if 0 <= c <= K:
            cnt += 1
print(cnt)
s = list(map(int, input().split(" ")))
n = s[0]
c = s[1]
ans = 0

for v in range(n+1):
    x = v
    for i in range(n+1):
        y = i
        if  0 <= (c - x - y) <= n:
                ans += 1
print(ans)
K, S = 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)
K, S = map(int, input().split())
res = 0
for x in range(K+1):
    y_z = S - x
    if y_z < 0:
        continue
    
    y_min = max(y_z-K,0)
    y_max = min(y_z,K)
    res += max(y_max-y_min+1,0)

print(res)
K,S = 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)
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)
a,b=list(map(int,input().split()))
count=0
for x in range(a+1):
    for y in range(a+1):
        if b < x+y:
            break
        if b-x-y <= a:
            count+=1
print(count)
k, s = map(int, input().split())
arr = [1 for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(sum(arr))
k,s = map(int,input().split())
c = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if 0 <= z <= k:
            c += 1
        
print(c)
K, S = 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)
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if i+j <= s and s <= i+j+k:
            count += 1
print(count)
k,s=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)
K,S = map(int, input().split())
# debug
# print([(A,B,S-A-B) for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K])
print(sum(1 for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K))
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

count = 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)
a=input().split()
K=int(a[0])
S=int(a[1])

n=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            n+=1
print(n)
import math
K,S = 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 K >= z:
            ans += 1
print(ans)
k, s = map(int, input().split())

ans = 0
for x in range(0, k+1):
    if s-x < 0 or s-x > 2*k:
        # no answer (y,z)
        continue
    elif 0 <= s-x <= k:
        ans += 1+s-x
    else:
        ans += k - (s-x-k) + 1

print(ans)
k,s = map(int,input().split())
cnt,x = 0,0
for y in range(k+1):
	for z in range(k+1):
		x = s-y-z
		if 0 <= x <= k:
			cnt += 1
print(cnt)
import math

k,s = map(int,input().split())
ans = 0

for i in range(k+1):
    s1 = s - i
    for j in range(s1+1):
        if j <= k and s1 - j <= k:
            ans += 1
print(ans)
a,b = 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)
K,S = 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)
k, s = 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(x, y, z)
print(count)
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)
#051_B
k,s=map(int,input().split())
print(sum([0<=s-x-y<=k for x in range(k+1) for y in range(k+1)]))
def main():
    K, S = 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)
 
main()
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(2*K - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))
K,S=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)
K,S = 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)
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S-i-j
        if 0<=k<=K:
            cnt += 1
print(cnt)
K,S = 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) & (z <=K):
            ans +=1
print(ans)
k,s = map(int,input().split())
c = 0

for y in range(k+1):
    for z in range(k+1):
        if 0 <= s-(y+z) <= k:
            c += 1
print(c)
k, s = 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)
k,s = 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)
k, s = 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)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
  for y in range(min(s-x+1, k+1)):
    z = s - x - y
    if 0 <= z <= k:
      ans += 1
print(ans)
k,s = 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:
            tmp = set([x,y,z])
            if len(tmp)==3:
                ans += 6
            elif len(tmp)==2:
                ans += 3
            else:
                ans += 1
print(ans)
import sys
readline = sys.stdin.readline

def main():
    K, S = map(int, readline().rstrip().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)


if __name__ == '__main__':
    main()
import itertools

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

cnt = 0

# K = list(range(K + 1))

for i, j in itertools.product(list(range(K + 1)), repeat=2):
    if 0 <= S - i - j <= K:
        cnt += 1

print(cnt)
n,m = map(int,input().split())
cnt = 0
for i in range(n+1):
  for j in range(n+1):
    if m-i-j <= n and m-i-j >= 0:
      cnt += 1	
print(cnt)
import math
import sys
from collections import deque
a,b=map(int,input().split())
count=0
for i in range(a+1):
  for j in range(a+1):
    if 0<=b-i-j<=a:
      count+=1
print(count)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if (0 <= s - x - y) and (s - x - y <= k):
                ans += 1
print(ans)
K, S = map(int, input().split())

ways = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            ways += 1

print(ways)
import itertools
a,b=(int(x) for x in input().split())
l = 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)
K, S = map(int, input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            count += 1

print(count)
k, s = map(int, input().split())
ct = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        z = s - x - y 
        if z >= 0 and z <= k:
            ct += 1
print(ct)
k, s = map(int, input().split())
l=[]
for x in range(0, k+1):
    for y in range(0, k+1):
        if s-x-y > k or s-x-y < 0:
            continue
        else:
            l.append(s-x-y)
print(len(l))
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

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

print(r)
k, s = map(int, input().split())
ans = 0

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

print(ans)
K, S = map(int, input().split())
ans = 0
for X in range(min(K, S)+1):
    for Y in range(min(K, S-X)+1):
        if 0 <= S-X-Y <= K:
            ans += 1 
print(ans)
K,S=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)
K, S = 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)
k ,s = map(int, input().split())

count = 0
for x in range(k+1):
    for y in range(k +1):
        if ((x + y) <= s) and ((s - (x + y)) <= k):
            count += 1
                
print(count)
K, S = 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)
# -*- coding: utf-8 -*-
K, S = map(int, input().split())
results = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            results += 1
print(results)
from operator import mul
from functools import reduce
def combinations_count(n, r):
    if n<r: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    K,S = map(int, input().split())
    ans = 0
    # x+y<=Sとなるように回す
    for x in range(K+1):
        for y in range(K+1):
            z = S-(x+y)
            if x+y<=S and 0<=z and z<=K: ans += 1
    print(ans)

main()
k,s = 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)
K, S = map(int, input().split())
ans = sum(0 <= S-x-y <= K for x in range(K+1) for y in range(K+1))
print(ans)
k, s = map(int, input().split())

def fun(k, s):
    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

    return count

print(fun(k, s))
k,s=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)
K, S = map(int, input().split())

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

print(ans)
K,S = 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)
from itertools import *
k, s = map(int, input().split())


t = sum(min(max(s - i + 1, 0), max(2*k - s + i +1, 0)) for i in range(k+1))
print(t)
# -*- coding: utf-8 -*-
k, s  = 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)
K, S = 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)
K, S = map(int, input().split())

c = 0
for x in range(K+1):
    for y in range(K+1):
        if x+y <= S and x+y+K >= S:
            c += 1
print(c)
K,S = 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) & (x + y + z == S):
            cnt +=1
print(cnt)
K,S = 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)
k, s = 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)
import sys

K, S = map(int, sys.stdin.readline().split())
ans = 0
for i in range(K+1):
  for j in range(K+1):
    if S - i - j < 0:
      break
    elif S - i - j > K:
      continue
    else:
      ans += 1
print(ans)
K, S = 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)
k , s = 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)
k, s = [int(e) for e in 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 = ans + 1
print(ans)
k,s = map(int,input().split())
x,y,z = k,k,k
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        if 0<= s - (i+j) <= k:
            cnt +=1
print(cnt)
K, S = 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)
K, S = 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)
import sys

input = sys.stdin.readline


def main():
    K, S = 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
            else:
                continue
    print(ans)


if __name__ == "__main__":
    main()
#SumofThreeIntegers
k, s = 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)
x,s=map(int,input().split())
n=x+1
a=0
for i in range(n):
    for j in range(n):
        if 0<=(s-(i+j))<=x:
            a+=1
print(a)
K,S=map(int,input().split())
count=0
for x in range(0,K+1,1):
    for y in range(0,K+1,1):
        if ((S-x-y)>=0)and((S-x-y)<=K):
            count=count+1
print(count)
k,s = map(int,input().split())
sum =0
for i in range(k+1):
  for l in range(k+1):
    if 0<=s-i-l<=k:
      sum += 1
print(sum)
K, S = [int(n) for n in input().split(' ')]

ans = 0

for x in range(0,K+1):
    for y in range(0,K+1):
        z = S - x - y
        if z >= 0 and z <= K:
            ans += 1
print(ans)
k,s=map(int,input().split())
n=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            n+=1
print(n)
K,S=map(int,input().split())

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))
  else:
    answer.append(s_z + 1)

print(sum(answer))
K, S = list(map(int, input().split()))
ans = 0
for X in range(0, K+1):
    for Y in range(0, K+1):
        Z = S-X-Y
        if Z>=0 and Z<=K: ans+=1
print(ans)
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)
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 or i+j+K < S:
            continue
        else:
            ans+=1
print(ans)
#2020-04-29
k, s = map(int,input().split())
cou = 0
for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <=k:
            cou += 1
print(cou)
k,s = map(int,input().split())
ans = 0

from itertools import product
for x,y in product(range(k+1), repeat=2):
    if 0 <= s-x-y <= k:
        ans +=1
print(ans)
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1):
    z = i + j
    
    if S - z >= 0 and S - z <= K:
      #print(i,j,S-z)
      ANS+=1
    else:
      if S - z <= 0:
      	break
print(ANS)
import itertools
k,s = map(int,input().split())

cnt = 0

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

print(cnt)