Problem:
 Score : 200 points    Problem Statement You are given two integers K and S . Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K . How many different assignments of values to X, Y and Z are there such that X + Y + Z = S ?      Constraints  2≤K≤2500   0≤S≤3K   K and S are integers.         Input The input is given from Standard Input in the following format:  K  S       Output Print the number of the triples of X, Y and Z that satisfy the condition.        Sample Input 1 2 2      Sample Output 1 6  There are six triples of X, Y and Z that satisfy the condition:   X = 0, Y = 0, Z = 2   X = 0, Y = 2, Z = 0   X = 2, Y = 0, Z = 0   X = 0, Y = 1, Z = 1   X = 1, Y = 0, Z = 1   X = 1, Y = 1, Z = 0        Sample Input 2 5 15      Sample Output 2 1  The maximum value of X + Y + Z is 15 , achieved by one triple of X, Y and Z .

Solution (Python):
def main():
  K, S = map(lambda i: int(i), input().split(' '))
  count = 0
  for X in range(K + 1):
    for Y in range(K + 1):
      Z = S - X - Y
      if Z >= 0 and Z <= K:
        count += 1
  print(count)

main()

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

Solution (Python):
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)

Solution (Python):
def solve():
    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)


if __name__ == '__main__':
    solve()

Solution (Python):
k, s = [int(x) for x in input().split()]

count=0
for x in range(k+1):
    for y in range(k+1):
        if (s-(x+y) <= k and s-(x+y) >=0):
            count+=1
print(count)

Solution (Python):

import sys
input = sys.stdin.readline


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)

Solution (Python):
K,S=map(int,input().split())
points=0
for i in range(K+1):
  for j in range(K+1):
    if 0<=S-i-j<=K:
      points+=1
print(points)

Solution (Python):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        if k >= s - (i + j) >= 0:
            cnt += 1
print(cnt)

Solution (Python):
k,s=map(int,input().split())
l=list(range(k+1))
count=0
for i in l:
    for j in l:
        q=s-i-j
        if 0<=q<=k:
            count+=1
            
print(count)

Solution (Python):
K, S = map(int , input().strip().split(" "))


count = 0
for x in range(K+1):
    if x > S :
        break
    elif S - x > 2*K:
        continue
    for y in range(K+1):
        if x + y > S:
            break
        elif S - (x+y) > K:
            continue
        count+= 1
print(count)

Solution (Python):
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)

Solution (Python):
k,s = list(map(int,input().rstrip().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)

Solution (Python):
k,s = map(int,input().split())
counter = 0
for i in range(k+1):
    rest = s-i
    for n in range(rest+1):
        if rest - n <= k and n <= k:
            counter += 1
print(counter)

Solution (Python):
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 and z <= k:
      count += 1
print(count)

Solution (Python):
def examB():
    K, S = LI()
    ans = 0
    for x in range(K + 1):
        if 0 <= S - x <= K:
            ans += S - x  + 1
        elif K < S - x <= 2 * K:
            ans += K - (S - x - K) + 1
    print(ans)

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Solution (Python):
k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):






        for y in range(l_k):






            sum = l_s- x-y 
            if 0<=sum and sum <= k:

                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))

Solution (Python):
K, S = map(int, input().split())
num = 0

for x in range(K + 1):
    ukou = S - x
    if (S >= x) and (ukou <= K * 2):
        y = K if K <= ukou else ukou
        z = ukou - y
        num += ((y + 1) - z)

print(num)

Solution (Python):
K,S=map(int,input().split())
point=0
for i in range(K+1):
  for j in range(K+1):
    if 0<=S-i-j<=K:
      point+=1
print(point)

Solution (Python):
import sys
input = sys.stdin.readline
import math

k,s = (int(x) for x in input().split())
r = max(s-k,0)
count = 0
for x in range(k+1):
    for y in range(k+1):
            if r<=x+y<=s:
                count += 1
print(count)

Solution (Python):
K, S = [int(i) for i in input().split()]

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

Solution (Python):
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=count+1
print(count)

Solution (Python):




import sys














def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k:
            count += s - x  + 1
        elif k < s - x <= 2 * k:
            count += k - (s - x - k) + 1

    
    print(count)


if __name__ == "__main__":
    
    main()

Solution (Python):




import sys














def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k * 2:     
            for y in range(k + 1):
                if 0 <= s - x - y <= k:
                    count += 1
    
    print(count)


if __name__ == "__main__":
    
    main()

Solution (Python):
K, S = 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)

Solution (Python):
K,S = map(int,input().split())

con = 0

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

Solution (Python):
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)

Solution (Python):
k, s = map(int, input().split())

count = 0

for i in range(k+1):
  a = i
  for j in range(k+1):
    b = j
    if a+b>s:
      break
    if s-(a+b)<=k:
      count+=1

print(count)

Solution (Python):
k,s = map(int, input().split())
count=0

for i in range(0,k+1):
    for j in range(0,k+1):
        if i+j>s:
            break
        if s-(i+j)<=k:
            count+=1
            
print(count)

Solution (Python):
k,s = map(int, input().split())

x=0
y=0
z=0

count=0

for i in range(0,k+1):
    x=i
    for j in range(0,k+1):
        y=j
        if x+y>s:
            break
        if s-(x+y)<=k:
            count+=1
            
        

print(count)

Solution (Python):

k, s = [int(s) for s in input().split()]
number = 0

for a in range(k + 1):
    for b in range(k + 1):
            if 0 <= (s - a - b) <= k:
                number += 1

print(number)

Solution (Python):
a,s  = map(int,input().split())

sum = 0
for i in range(0,a+1):
    for j in range(0,a+1):
        if 0 <= s-i-j <= a:
            sum += 1
print(sum)

Solution (Python):
K,S=map(int,input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        sumz=S-x-y
        if sumz>=0 and sumz<=K:    
            count+=1
print(count)

Solution (Python):
K,S = 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)

Solution (Python):
k,s=map(int,input().split())
res=0
for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j and s-i-j<=k:res+=1
print(res)

Solution (Python):
k,s=map(int,input().split())
cnt=0
for i in range(0,k+1):
    for j in range(0,k+1):
        if s-i-j<=k and 0<=s-i-j:
            cnt+=1
print(cnt)

Solution (Python):


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 and S-i-j<=K:
            cnt+=1
print(cnt)

Solution (Python):
K,S=map(int,input().split())
ans=0
for x in range(0,K+1):
  for y in range(0,K+1):
    if 0<=S-x-y<=K:
      ans+=1
print(ans)

Solution (Python):

import sys

k, s = map(int,sys.stdin.readline().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
else:
    print(cnt)

Solution (Python):
K,S = map(int,input().split())

result = 0
for X in range(K + 1):
  YZ = S - X
  if 0 <= YZ <= K:
    result += YZ + 1
  elif K < YZ <= 2 * K:
    result += 2 * K + 1 - YZ
  
print(result)

Solution (Python):
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)

Solution (Python):
K,S = map(int,input().split())
flag = 1
s = 0
for l in range(K+1):
  for m in range(K+1):
    if (0 <= S-l-m)and(S-l-m<=K):
      s = s+1
print(s)

Solution (Python):
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 S-j-i >= 0:
      ans += 1
      
print(ans)

Solution (Python):
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
  if s-x<0:
    break
  elif s-x<=k:
    cnt+=(s-x)+1
  elif s-x>2*k:
    cnt+=0
  elif s-x>k:
    cnt+=2*k-(s-x)+1
print(cnt)

Solution (Python):
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Solution (Python):
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Solution (Python):
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Solution (Python):
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Solution (Python):
k,s=map(int,input().split())
c=0
r=min(k,s)+1
for i in range(r):
  for j in range(r):
    y=s-i-j
    if 0<=y and y<=k:
      c+=1
print(c)

Solution (Python):
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)

Solution (Python):
k,s=map(int,input().split())
ans=0
def als(n):
  if 0<=n<=k:
    return n+1
  elif k+1<=n<=2*k:
    return 2*k+1-n
  else:
    return 0
for i in range(k+1):
  ans+=als(s-i)
print(ans)

Solution (Python):
k,s=map(int,input().split())
c=0
r=min(k,s)
for i in range(r+1):
  for j in range(r+1):
    if 0<=s-i-j and s-i-j<=k:
      c+=1
print(c)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
K,S = map(int,input().split())
ans = 0
for i in range(K+1):
    if i > S:
        break
    for j in range(K+1):
        if i + j > S:
            break
        elif 0 <= S - (i + j) <= K:
            ans += 1
print(ans)

Solution (Python):
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)

Solution (Python):
k, s = map(int, input().split())

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

Solution (Python):
k,s = map(int,input().split())
ans  = 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:
      ans += 1
print(ans)

Solution (Python):
k, s = map(int, input().split())
pattern = 0

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

print(pattern)

Solution (Python):
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 k >= z >= 0:
            count += 1
            
print(count)

Solution (Python):
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 x+y<=s and z<=k:
      cnt+=1
print(cnt)

Solution (Python):
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 and z<=K:
            count += 1
print(count)

Solution (Python):
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)

Solution (Python):
K, S =[int(i) for i in 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)

Solution (Python):
K, S =[int(i) for i in input().split()]
C = 0
for X in range(K+1):
    for Y in range(K+1):
        if X+Y <= S <= X+Y+K:
            C += 1
print(C)

Solution (Python):
from sys import stdin
n = input().split(' ')
c = 0
K = int(n[0])
S = int(n[1])
for i in range(int(K)+1):
    for j in range(int(K)+1):
        if(S-(i+j) <= K and S>=i+j):
            c+=1
                
print(c)

Solution (Python):
k, s = map(int, input().split())
cnt = 0

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

print(cnt)

Solution (Python):
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 = count +1
print(count)

Solution (Python):
K,S=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        count+=X+Y<=S<=X+Y+K

print(count)

Solution (Python):

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)

Solution (Python):
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)

Solution (Python):
k, s = 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)

Solution (Python):
k,s=map(int,input().split())
 
i=0
 
for l in range(k+1):
  for m in range(k+1):
    if 0<=s-l-m<=k:
      i+=1
      
print(i)

Solution (Python):
k,s = map(int,input().split())
ans = 0
for x in range(0,k+1):
    for y in range(0,k+1):
        d = s-x-y
        if 0 <= d and d <= k:
            ans += 1
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
K, S =  map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if S - (X + Y) >= 0 and K >= S - (X + Y):
            ans += 1

print(ans)

Solution (Python):
a,b = map(int,input().split())
cnt=0
for x in range(a+1):
    for y in range(a+1):
        z = b-x-y
        if 0<=z<=a and x+y+z==b:
            cnt+=1
print(cnt)

Solution (Python):
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 z >= 0 and z <= k:
      count += 1

print(count)

Solution (Python):
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)

Solution (Python):
K, S = [int(x) for x in input().split()]
count = 0
for x in range(K+1):
    
    if 0 <= S - x <= K: 
        count += S - x + 1 
        
    elif K < S - x <= 2 * K:
        count += 2 * K - S + x + 1 
        
        
    else: 
        
        
        continue
print(count)

Solution (Python):
k, s = [int(x) for x in input().split()]
count = 0
for x in range(k+1):
    if x <= s:       
        for y in range(k+1):
            if x + y <= s:
                z = s - (x + y)
                if  z <= k:
                    count += 1
            
print(count)

Solution (Python):
K, S = map(int, input().split())

result = 0

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

Solution (Python):
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)

Solution (Python):
K,S = map(int,input().split())
cnt = 0
for i in range(min(K,S)+1):
    for j in range(min(K,S-i)+1):
        if 0<=S-i-j<=K:
            cnt += 1
print(cnt)

Solution (Python):
k,s=map(int,input().split())
count=0
for i in range(k+1):
    for j in range(k+1):
        if i+j<=s:
            if i+j+k>=s:
                count+=1
print(count)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    if (s - i) / 2 > k:
        continue
    for j in range(k+1):
        z = s - i - j
        if 0 <= z <= k:
            count += 1

print(count)

Solution (Python):
k,s = map(int,input().split())
c = 0
for x in range(0,k+1):
  for y in range(0,k+1):
    if s-x-y >= 0 and s-x-y <= k:
      c += 1
print(c)

Solution (Python):



import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 15"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
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)

Solution (Python):
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 z >= 0 and z <= k:
            count += 1

print(count)

Solution (Python):
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    if 0 <= S - i < K:
        count += S - i + 1
    elif K <= S - i <= 2 * K:
        count += 2 * K - S + i + 1
    else:
        continue
print(count)

Solution (Python):
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)

Solution (Python):
import sys
import math

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

ans = 0
for i in range(K+1):
    if 2*K < S - i:
        continue
    for j in range(K+1):
        if K < S - i - j:
            continue
        if S >= i + j:
            ans += 1


print(ans)

Solution (Python):
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)

Solution (Python):
"""
AtCoder Beginner Contest 051
B - Sum of Three Integers
"""

if __name__ == "__main__":
    K, S = map(int, input().split())

    ans = 0
    A = [i for i in range(K+1)]
    for x in A:
        for y in A:
            if x + y > S or S - (x + y) > K:
                continue
            ans += 1

    print(ans)

Solution (Python):
"""
AtCoder Beginner Contest 051
B - Sum of Three Integers
"""

if __name__ == "__main__":
    K, S = map(int, input().split())

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

    print(ans)

Solution (Python):
k,s=map(int,input().split())
counter=0

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

print(counter)

Solution (Python):
K,S = 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)

Solution (Python):
K_S = input().split()
K = int(K_S[0])
S = int(K_S[1])

total_xy = -1
expected_z = -1
range_xy = range(0, K + 1)
count_pattern = 0
for x in range_xy:
    for y in range_xy:
        expected_z = S - (x + y)
        if expected_z >=0 and expected_z <= K:
            count_pattern += 1

print(count_pattern)

Solution (Python):
K_S = input().split()
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)

Solution (Python):
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)

Solution (Python):
K,S=map(int,input().split())
count=0

for i in range(min(K+1,S+1)):
    for j in range(min(K+1,S+1)):
        if K>=S-i-j>=0:

            count+=1

print(count)

Solution (Python):
K,S=map(int,input().split())
count=0

for i in range(min(K+1,S+1)):
    for j in range(min(K+1,S+1)):
        if K>=S-i-j>=0:

            count+=1

print(count)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
k,s=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)

Solution (Python):
k,s=map(lambda x: int(x), input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j>=0 and s-i-j<=k:
            ans+=1
print(ans)

Solution (Python):
K , S = 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)

Solution (Python):
K , S = 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)

Solution (Python):
k, s = map(lambda x: int(x), input().split())
count = 0
for i in range(max(s-k,0),min(s,2*k)+1):
    count += k+1-abs(i-k)
print(count)

Solution (Python):

import sys


def solve(K: int, S: int):
    answer=0
    for i in range(K+1):
        for j in range(K+1):

            if 0<=S-i-j<=K:
                answer+=1
                    
    print(answer)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  
    S = int(next(tokens))  
    solve(K, S)

if __name__ == '__main__':
    main()

Solution (Python):
K,S = [int(i) for i in input().rstrip().split()]

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

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

Solution (Python):
k,s=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]))

Solution (Python):
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        if S - (i + j) >= 0 and S - (i + j) <= K:
            c += 1
print(c)

Solution (Python):

ans=0 
k,s=map(int,input().split())
for a in range(k+1):
    for b in range(k+1):
        c=s-a-b 
        if c>=0 and c<=k: 
            ans+=1 
print(ans)

Solution (Python):
count = 0
K,S = map(int,input().split())

for i in range(K+1):
	for j in range(K+1):
			k = S - i - j
			if 0 <= k <= K:	
				count += 1
				
print(count)

Solution (Python):
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z = S - i - j
        if K >= Z >= 0:
            count += 1
print(count)

Solution (Python):
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)

Solution (Python):
K, S = map(int, input().split())

count = 0
for i in reversed(range(K+1)):
    tmp = S - i
    for j in reversed(range(K+1)):
        tmp_tmp = tmp -j
        if tmp_tmp < 0 or tmp_tmp > K:
            continue
        else:
            
            count += 1

print(count)

Solution (Python):
K, S = map(int, input().split())
cnt = 0
for i in range(min(K, S)+1):
    for j in range(min(K, S)+1):
        if S-i-j <= min(K, S) and S-i-j >=0:
            cnt += 1
print(cnt)

Solution (Python):
from fractions import gcd
K, S = map(int, input().split())
ans = 0
for z in range(0, min(S + 1, K + 1)):
    
    if S - z <= 2 * K:
        x1 = min(K, S - z)
        y1 = S - z - x1

        y2 = min(K, S - z)
        x2 = S - z - y2

        ans += gcd(abs(x1 - x2), abs(y1 - y2)) + 1
        
print(ans)

Solution (Python):
KS = list(map(int,input().split()))
sum =0
K = KS[0]
S = KS[1]
N=K+1
for i in range(N):
	if(S-i) > 2*K:
		continue
	for m in range(N):
		if(i+m) > S:
			break
		if (S -m-i) <= K:
			sum+=1
print(sum)

Solution (Python):
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 z >=0 and z<=k:
            count += 1

print(count)

Solution (Python):
K, s = map(int, input().split())

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

Solution (Python):

K,S = 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)

Solution (Python):
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 not (0 <= z <= k):
            continue
        cnt += 1
print(cnt)

Solution (Python):
k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        t = s - (i + j)
        if 0 <= t <= k:
            count += 1
print(count)

Solution (Python):
K,S = map(int,input().split())
counter = 0
for x in range(0,K+1):
  for y in range(0,K+1):
    if S - x - y <= K and S - x - y >= 0:
      counter += 1
print(counter)

Solution (Python):
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(K+1):
    if S-(i+j) >=0 and S-(i+j)<=K:
      ans+=1
print(ans)

Solution (Python):
import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    mi = min(k, s)
    ma = max(k, s)
    for i in range(mi + 1):
        for j in range(mi + 1):
            if 0 <= s - i - j and s - i - j <= k:
                res += 1
    print(res)

Solution (Python):
import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - i - j <= k:
                res += 1
    print(res)

Solution (Python):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=i+j<=s and s-i-j<=k:
            ans+=1
print(ans)

Solution (Python):
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
  for y in range(0,k+1):
    tmp = s - (x+y)
    if tmp>=0 and tmp<k+1:
      ans+=1
print(ans)

Solution (Python):
k,s=map(int,input().split())
ans=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:
      ans+=1
print(ans)

Solution (Python):

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

K+=1

count=0
for i in range(K):
    for j in range(0, K):
        tmp = S - (i + j)
        if tmp>=0 and tmp<K:
            count+=1


print(count)

Solution (Python):
K,S = 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)

Solution (Python):
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)

Solution (Python):
k,s=map(int,input().split())

count=0
for x in range(k+1):
    for y in range(k+1):    
        if s-(x+y) <= k and  s-(x+y) >= 0: 
            count +=1
        
                
print(count)

Solution (Python):
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)