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):
k,s=[int(i) for i in 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):
import sys; input = lambda: sys.stdin.readline()
k, s = map(int, input().split())
cnt = 0
for i in range(0, k + 1):
    for j in range(0, k + 1):
        if 0 <= s - i - j <= k:
            cnt += 1
print(cnt)

Solution (Python):
import sys

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

result = 0

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

Solution (Python):
import sys

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

result = 0

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

Solution (Python):
import sys

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

result = 0

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

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

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

print(result)

Solution (Python):
k,s = map(int, input().split())
count = 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 and y==z:
                count += 1
            elif x==y or y==z or z==x:
                count += 3
            else:
                count += 6
        
print(count)
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 s-i-j >= 0 and s-i-j<=K:
      cnt+=1
print(cnt)

Solution (Python):
if __name__ == "__main__":
    K, S = [int(x) for x in 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)

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 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 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())
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] = 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 in range(K+1):
            count+=1
print(count)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

K, S = inm()


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


print(solve())

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 = 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)

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-z-y <= k]))

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

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    K, S = mi()
    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)

if __name__ == '__main__':
    main()

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

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)

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 p in range(k+1):
  for q in range(k+1):
    r=s-p-q
    if 0<=r<=k:
      cnt+=1
print(cnt)

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

Solution (Python):

def resolve():
    ks = input().split(" ")
    k = int(ks[0])
    s = int(ks[1])

    n = 0

    for zz in range(k+1):
        for yy in range (k+1):
                if (0 <= s-(yy+zz) <= k):
                    n += 1

    print(n)

if __name__ == "__main__":
    resolve()

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 = map(int,input().split())

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

print(cnt)

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)) <= k and (i + j) <= s:
            c += 1

print(c)

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

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

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

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

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, S = il()

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


if __name__ == '__main__':
    main()

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




count = 0


x = 0
y = 0
z = 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):
from math import factorial
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


k, s = LI()
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 = map(int, input().split())
a = 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:
            a += 1

print(a)

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

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

ans = 0

for i in range(K+1):
  for j in range(K+1):
    x = S - i - j
    if 0<=x and x<=K:
      ans = ans + 1
    else:
      ans = ans

print(ans)

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

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

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

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

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

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):
a,b=map(int,input().split())
ans=0
for i in range(a+1):
    for j in range(a+1):
        if 0<=(b-i-j)<=a:
                ans+=1
print(ans)

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

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

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

print(a)

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):
        k = S-i-j
        if k <= K and i <= K and j <= K and k >= 0:
            ans += 1

print(ans)

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

Solution (Python):
def readinput():
    k,s = list(map(int,input().split()))
    return k,s

def main(k,s):
    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
    return count

if __name__=='__main__':
    k,s=readinput()
    ans=main(k,s)
    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):
        z = S - x - y
        if 0 <= z <= 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):
        if 0<=s-x-y<=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((S-i-j)<=K and 0<=S-i-j):
            count=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 x+y > s: break
    elif 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):
    z = (s - i - j)
    if 0<= z <= 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):
        if 0<=s-x-y<=k:
            ans+=1
print(ans)

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


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

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

Solution (Python):
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(max(k+1,min(s-k,k+1))):
        ans += 1 if 0<=s-i-j<=k else 0
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 S-x-y<=K and S-x-y>=0:
            cnt+=1
print(cnt)

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

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

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

'''from itertools import product
for x,y,z in product(range(k+1), repeat=3):
    
    if x+y+z == s:
        ans += 1'''
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())
def two_sum(k, s):
    if s < 0:
        return 0
    elif k >= s:
        return s + 1
    elif s//2 > k:
        return 0
    else:
        return s + 1 - 2 * (s - k)

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

Solution (Python):
"""
int 
float 


for name in fruits: 
    print(name)
    

list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

exit(0) 
"""
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 0<=Z<=K:
            count += 1

print(count)

Solution (Python):
"""
int 
float 


for name in fruits: 
    print(name)
    

list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

exit(0) 
"""
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 0<=Z<=K:
            count += 1

print(count)

Solution (Python):
def main():
  result = 0
  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:
        result += 1
  print(result)
if __name__ == "__main__":
  main()

Solution (Python):
def main():
  result = 0
  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:
        result += 1
  print(result)
if __name__ == "__main__":
  main()

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 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 = map(int,input().split())
ans = 0
if 3*K < S:
  pass
else:
  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 = map(int, input().split())

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

Solution (Python):

"""
Created on Mon Jun 15 13:34:38 2020

@author: NEC-PCuser
"""

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

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

print(count)

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

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):
import sys, re
from math import ceil, floor, sqrt, pi, factorial
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    k, s = i_map()

    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)

if __name__ == '__main__':
    main()

Solution (Python):
[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
    else:
      continue
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 and s-x-y <=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):
        if 0 <= S-x-y and S-x-y<=K:
            ans +=1

print(ans)

Solution (Python):



import os
import sys







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


if __name__ == '__main__':
    main()

Solution (Python):
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 0<= Z <= K: res += 1
print(res)

Solution (Python):

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

n_int = 0

for z in range(min(K, S)+1):
    for y in range(min(K, S-z)+1):
        if S-y-z <= K:
            n_int += 1

print(n_int)

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

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

Solution (Python):
import itertools

def main():
    k,s=map(int,input().split())
    count = 0
    for x,y in itertools.product(range(k+1), repeat=2):
        if 0 <= s-(x+y) <= k:
            count += 1
    print(count)
        
if __name__ == "__main__":
    main()

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

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(min(s-x+1, 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()]

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

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())
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):
def myAnswer(K:int,S:int) -> int:
   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
   return ans

def modelAnswer():
   return
def main():
   K,S = map(int,input().split())
   print(myAnswer(K,S))
if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer(K:int,S:int) -> int:
   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
   return ans

def modelAnswer():
   return
def main():
   K,S = map(int,input().split())
   print(myAnswer(K,S))
if __name__ == '__main__':
   main()

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):
import math

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

kotae = 0

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


print(kotae)

Solution (Python):
import math

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

kotae = 0

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


print(kotae)

Solution (Python):


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

if __name__=="__main__":
    main2()

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 <= K and S - x- y >=0:
      cnt+=1
print(cnt)

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


def calculate(k, s):
    result = 0
    for x in range(k, -1, -1):
        if x > s:
            continue

        for y in range(k, -1, -1):
            if y > s:
                continue
            z = s - x - y

            if z > k:
                continue

            if z < 0:
                continue

            result = result + 1


    print(result)


calculate(K, S)

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

a = min(k,s)

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

print(ans)

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

print(count)

Solution (Python):
import itertools

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):
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):
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) and S - (x + y) <= K:
            n += 1
print(n)

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

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):
nums = [int(e) for e in input().split()]

count=0
for i in range(nums[0]+1):
    for j in range(nums[0]+1):
        if 0<=nums[1]-i-j<=nums[0]:
            count=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):
    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 X in range(K+1):
    for Y in range(K+1):
        com=S-(X+Y)
        if(com>=0 and com<=K):
            count+=1
        else:
            pass
print(count)

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

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

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 = [int(n) for n in input().split()]

count = 0

for x in range(min(S, K)+1):
    for y in range(x+1):
        z = S - x - y
        if z <= y and z >= 0:
            num_distinct = len({x,y,z})
            if num_distinct == 1:
                count += 1
            if num_distinct == 2:
                count += 3
            if num_distinct == 3:
                count += 6

print(count)

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

Solution (Python):

import sys


def solve(K: int, S: int):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                count += 1
    print(count)
    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 = 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 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 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())
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())
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)