CodeEff/ECCO huggingface dataset:
# Original solution
k, s = list(map(int, 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 = list(map(int, input().split(' ')))

count = 0

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

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

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        for k in range(K + 1):
            s = i + j + k
            if S == s:
                ans += 1
                break

print(ans)

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

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

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

for i in range(K + 1):
    if i > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

print(ans)

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

for i in range(min(S + 1, K + 1)):
    s = S - i
    if s > 2 * K:
        continue
    ans += min(K, s) - max(0, s - K) + 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 x + y <= s and x + y >= s - k:
        cnt += 1
print(cnt)
# Original solution
import math
#-------------
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) == 0:
        cnt += 1
print(cnt)

# Optimized solution
import math
#-------------
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 = (int(i) for i in input().split())
ans = 0
for i in range(k+1):
 for j in range(k+1):
  for l in range(k+1):
    if i+j+l == s:
      ans += 1
print(ans)

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

counter = 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:
                counter += 1

print(counter)

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

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

print(counter)
# Original solution
K,S = [int(i) for i in 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 = [int(i) for i in 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
def is_same(x, y, z, s):
    return x+y+z == s


k, s = [int(e) for e in input().split()]
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if is_same(x,y,z,s):
                ans += 1
print(ans)

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

ans = 0
if(s == 0):
  print((1))
  exit()
elif(s == 3*k):
  print((1))
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    for k in range(0,k+1):
      if(i + j + k == s):
        ans += 1
        
print(ans)

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

ans = 0
if(s == 0):
  print((1))
  exit()
elif(s == 3*k):
  print((1))
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z >= 0 and z <= k):
      ans += 1
        
print(ans)
# Original solution
# -*- coding: utf-8 -*-


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    while l >= 0:
        t_sum = s - l
        m = k
        if t_sum > 2*k:
            break
        if m < k:
            m = k
        while m >= 0:
            n = s - l - m
            if n > k:
                n = k
            if l + m + n < s:
                break
            while n >= 0:
                if l + m + n == s:
                    ans += 1
                if l + m + n < s:
                    break

                n -=1
            m -= 1
        l -= 1

print(ans)

# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  3 13:34:09 2020

@author: ito
"""


# -*- coding: utf-8 -*-

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

ans = 0

for x in range(k+1):
    for y in range(k+1):
        
        sat_z = s - x - y
        
        if sat_z >= 0 and sat_z <= k:
            ans += 1
            
print(ans)
# Original solution
# -*- coding: utf-8 -*-


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k or l + m + n < s:
                break
            
            while n >= 0:
                if l + m + n == s:
                    ans += 1
                if l + m + n < s:
                    break

                n -=1
            m -= 1
        l -= 1

print(ans)


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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k:
                break
            
            if n >= 0:
                ans += 1

            m -= 1
        l -= 1

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k:
                break
            
            if n >= 0:
                ans += 1

            m -= 1
        l -= 1

print(ans)


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

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

for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l+m+n==s:
                c+=1
            elif l+m+n>s:
                break
print(c)

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

for l in range(k+1):
    for m in range(k+1):
        if 0<=s-l-m and s-l-m<=k:
            c+=1
print(c)
# Original solution
import itertools
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
# -*- coding: utf-8 -*-
k, s = list(map(int,input().split()))
count = 0
if k == s/3:
  print((1))
  exit()
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        #print(x,y,z)
        count += 1
print(count)


# Optimized solution
# -*- coding: utf-8 -*-
k, s = list(map(int,input().split()))
count = 0
if k == s/3:
  print((1))
  exit()
for x in range(k+1):
  for y in range(k+1):
    z = s - x -y
    if (z >= 0 and z <= k):
      #print(x,y,z)
      count += 1
print(count)
# Original solution
k, s = list(map(int, input().split()))
ans = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l == s:
                ans += 1
print(ans)

# Optimized solution
k, s = list(map(int, input().split()))
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if s <= i+j+k and i+j <= s:
            ans += 1
print(ans)
# Original solution
k,s=list(map(int,input().split()))
ac=[]
nums=[]
for i in range(k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if i+j+l==s:
        ac.append((i,j,l))
for i in range(len(ac)):
  if len(set(ac[i]))==1:
    nums.append(1)
  elif len(set(ac[i]))==2:
    nums.append(3)
  else:
    nums.append(6)
print((sum(nums)))

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

print(ans)
# Original solution
def check(x, y, K, S):
  if x + y > S:
    return False
  for z in range(K+1):
    if x + y + z == S:
      return True
  return False

K, S = list(map(int, input('').split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    if check(x, y, 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):
    if x + y <= S and x + y + K >= S:
      count += 1
print(count)
# Original solution
k, s = list(map(int, input().split()))

count=0
for i in range(k+1):
  if i+2*k-s >=0:
    for j in range(k+1):
      if i+j+k-s>=0:
        for h in range(k+1):
          if i+j+h ==s:
            count+=1
print(count)

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

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

count=0
for i in range(k+1):
  if i+2*k-s >=0:
    for j in range(k+1):
      if (s-(i+j)<=k)&(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)&(s-(i+j)>=0):
      count+=1
print(count)
# Original solution
import itertools
K, S = list(map(int, input().split()))
cnt = 0
for i in itertools.product(list(range(K+1)), repeat=3):
    cnt += sum(i) == S
print(cnt)

# Optimized solution
K, S = list(map(int, input().split()))
K += 1
cnt = 0
for i in range(K):
    if i+K*2<=S : continue
    if i>S : continue
    for j in range(min(K, S-i+1)):
        if i+j+K<=S : continue
        if i+j>S : break
        cnt += 1
print(cnt)
# Original solution
K,S = list(map(int,input().split()))
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        for k in range(0,K+1):
            if(i+j+k==S):
                ans += 1
            else:
                pass
print(ans)


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

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

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

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

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

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

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

# Optimized solution
# ABC051 B - Sum of Three Integers
K,S = list(map(int,input().split()))
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        k = S-i-j
        if 0<=k<=K:
                ans += 1
print(ans)
# Original solution
def abc():
    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)


abc()


# 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()))
ans=0
for x in range(k+1):
    for y in range(min(k+1,s+1-x)):
        z=s-x-y
        if x+y<=s and x<=k and y<=k 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(min(k+1,s+1-x)):
        z=s-x-y
        if 0<=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 l in range(k + 1):
            if i+j+l == s:
                ans+=1

print(ans)

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

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        if i+j<=s and i+j+k>=s:
            ans += 1

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

def fact(n):
  return sum([x for x in range(1,n+1)])

ans = 0
r = 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:
          ans += 1
        elif (x==y) or (x==z) or (y==z):
          ans += fact(2)
        else:
          ans += fact(3)

print(ans)


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

def fact(n):
  return sum([x for x in range(1,n+1)])

ans = 0
r = 0
for x in range(k+1):
  for y in range(x,k+1):
    if 0 <= s - (x+y) <= k:
      if (x==y):
          ans += 1
      else:
          ans += 2

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

# Optimized solution

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

def est():
  cnt = 0
  for x in range(k+1):
    for y in range(k+1):
      if s-(x+y) >=0 and s-(x+y) <= k:
        cnt += 1
  return cnt
print((est()))
# Original solution
k,s = list(map(int,input().split()))
#x + y + z = s z < k
counter = 0
for i in range(k + 1):
    if i > s:
        break
    for j in range(k + 1):
        if  i + j > s :
            break
        z = s - i - j
        if 0 <= z and z <= k:
            counter += 1

print(counter)


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

print(counter)
# Original solution
# https://atcoder.jp/contests/abc051/tasks/abc051_b

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

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(K + 1):
    if i + K + 1 + K + 1 < S:
        continue
    for j in range(K + 1):
        if i + j + K + 1 < S:
            continue
        if 0 <= S - i - j <= K:
            ans += 1

print(ans)


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

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            ans += 1
print(ans)


# Optimized solution
# https://atcoder.jp/contests/abc051/tasks/abc051_b

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

# initialize
ans = 0

# logic: 全探索: 基本形
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):
    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):
    if 0 <= S-X-Y <= K:
      count += 1
print(count)
# Original solution
k, s = list(map(int, input().split()))
ans = 0
for x in range(min(s, k) + 1):
    for y in range(min(s-x, k) + 1):
        for z in range(min(s-x-y, k) + 1):
            if x + y + z == s:
                ans += 1
else:
    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
else:
    print(ans)
# Original solution
K, S = list(map(int, input().split()))
answer = 0

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

# 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()))
c = 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:
                    c += 1
                elif x == y or y == z:
                    c += 3
                else:
                    c += 6

print(c)

# Optimized solution
k, s = list(map(int, input().split()))
c = 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:
                c += 1
            elif x == y or y == z:
                c += 3
            else:
                c += 6

print(c)
# 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):
      if i + j + k == S:
	      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):
        if x + y > S:
            continue
        z = S - x - y
        if 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):
        if x + y > S:
            continue
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)

# 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 K >= k >= 0:
            ans += 1
print(ans)
# Original solution
K, S = list(map(int, input().split()))

counter = 0
for h in range(K + 1):
    for i in range(K + 1):
        for j in range(K + 1):
            if h + i + j == S:
                counter += 1
print(counter)

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