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

import sys
import itertools

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

n = 0
for iz in range(s // 3, k + 1):
    for iy in range((s - iz) // 2, k + 1):
        x = s - iy - iz
        if 0 <= x <= iy <= iz:
            y, z = iy, iz
            
            n += len(set(itertools.permutations((x, y, z))))

print(n)

Solution (Python):

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

Solution (Python):
a, b = map(int, input().split())
c = 0
for i in range(a+1):
    for j in range(a+1):
        if 0 <= b - i - j <= a:
            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 z>=0 and z<=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):
		z = S-i-j
		if z>=0 and z<=K:
			cnt += 1

print(cnt)

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

n = 0

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

print(n)

Solution (Python):
n,s=map(int,input().split())
ans=0
m=min(s-n*2,n,s)
for i in range(n+1):
  for j in range(n+1):
    if -1<s-i-j<n+1:
      ans+=1
print(ans)

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

Solution (Python):
n,s=map(int,input().split())
ans=0
for i in range(n+1):
  if s-i>n*2 or s-i<0:
    continue
  for j in range(n+1):
    if -1<s-i-j<n+1:
      ans+=1
print(ans)

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

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

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

count = 0
for x in range(k+1):
    for y in range(min(s-x+1, k+1)):
        z = s - x - y
        if 0 <= z 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):

        if x+y <= S and 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  S-i-j>=0:
            count+=1
print(count)

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

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

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

res = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            if x + y + k >= s:
                res += 1
        else:
            break

print(res)

Solution (Python):
nyu = input()
nyu = nyu.split()

k = int(nyu[0])
s = int(nyu[1])

n = 0
for x in range(k+1):
  for y in range(k+1):
    if x+y > s:
      break
    elif s - (x+y) > k:
      
      continue;
    else:
      n +=1;

print(n)

Solution (Python):
nyu = input()
nyu = nyu.split()

k = int(nyu[0])
s = int(nyu[1])

n = 0
for x in range(k+1):
  for y in range(k+1):
    if x+y > s or s - (x+y) > k:
      
      continue;
    else:
      n +=1;

print(n)

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

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

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


		
def main():
	k, s = map(int, input().split())
	c=0
	for x in range(k+1):
		for y in range(k+1):
			ccc=s-(x+y)
			c+=1 if ccc <= k and 0<= ccc else 0
	
	print(c)
	
	


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def 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)
if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):
k,s=map(int,input().split())
x=0
m=min(s+1,k+1)
for a in range(m):
  for b in range(m):
    if a+b>s or a+b<s-k:
      continue
    x+=1
print(x)

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

ans = 0
for i in reversed(range(k + 1)):
    start = min(k, n - i)
    if n - i - start > k:
        continue
    for j in reversed(range(start + 1)):
        if(n - i - j <= k):
            
            ans += 1

print(ans)

Solution (Python):
k,s=map(int,input().split())
x=0
m=min(s+1,k+1)
for a in range(m):
  for b in range(m):
    if a+b>s or a+b<s-k:
      continue
    x+=1
print(x)

Solution (Python):
k,s=map(int,input().split())
ans=0
x=min(k+1,s+1)
y=max(0,s-k-k)
for i in range(y,x):
    for j in range(y,x):
        if i+j>s: break
        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):
from sys import exit, stdin
K, S = [int(_) for _ in stdin.readline().rstrip().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())
c = 0
for i in range(max(0, S-K*2), min(K+1, S+1)):
    for j in range(max(0, S-i-K), min(K+1, S-i+1)):
       c += 1
print(c)

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

Solution (Python):


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

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

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

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

print(n_combinations)

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

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

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

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

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

print(ans)

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

ans = 0
for i in range(0, min(S, K)+1):
    for j in range(0, min(S-i, K)+1):
        if 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):
        if 0 <= S - (x + y) <= K:
            ans += 1

print(ans)

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






l=[]
for i in range(max(0,s-2*k),min(s,k)+1):
    l.append(min(s-i,k)+1-max(0,s-(i+k)))
    
print(sum(l))

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

l=[]

for i in range(max(0,s-2*k),min(s,k)+1):
    l.append(min(s-i,k)+1-max(0,s-(i+k)))
    
        

print(sum(l))

Solution (Python):
import numpy as np
K,S = map(int,input().split())
x1 = np.ones(K+1, dtype=np.int32)
x2 = np.convolve(x1,x1)
x3 = np.convolve(x1,x2)
answer = x3[S]
print(answer)

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 0 <= s - x - y <= k: 
                counter += 1

print(counter)

Solution (Python):
k,s=map(int,input().split());k+=1;print(sum(k>s-I//k-I%k>=0for I in range(k*k)))

Solution (Python):

import sys
from operator import itemgetter

from fractions import gcd

from math import ceil, floor

from copy import deepcopy

from itertools import accumulate






from collections import Counter
import math
from functools import reduce

input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



def solve(K: int, S: int):
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S - i - j <= K:
                ans += 1
    print(ans)


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

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

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

print(ans)

Solution (Python):
k,s=map(int,input().split())
print(sum([max(0,min(k,s-i)-max(0,s-i-k)+1) for i in range(k+1)]))

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 time
import re
import math
import fractions

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 S-x-y<=K and S-x-y>=0:
                count+=1
    print(count)
start=time.time()
main()

Solution (Python):

import time
import re
import math
import fractions

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(x+y>S):break
            if S-x-y<=K and S-x-y>=0:
                count+=1
    print(count)
start=time.time()
main()

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

Solution (Python):



def read_h(typ=int):
    return map(typ, input().split())


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def main():
    K, S = read_h()
    cnt = 0
    for x in range(K + 1):
        for y in range(min(S - x, K) + 1):
            z = S - x - y
            if z <= K:
                cnt += 1

    print(cnt)


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 = [int(v) for v in 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 = 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()))
ans = 0
for i in range(min(S + 1, K + 1)):
  for j in range(min(S + 1, 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(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())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if (z>=0)&(z<=k):
            cnt=cnt+1
print(cnt)

Solution (Python):
from sys import stdin
K,S = [int(x) for x in stdin.readline().rstrip().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(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())
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())
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 = (s+2)*(s+1)/2
b = (s-k+1)*(s-k)/2
c = (s-2*k)*(s-2*k-1)/2
 
if s <= k:
    print(int(a))
elif s <= 2*k:
    print(int(a-3*b))
elif s <= 3*k:
    print(int(a-3*b+3*c))

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

count = 0
for i in range(n+1):
    for j in range(n+1):
        if s-i-j <= n and s-i-j >= 0:
            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())

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

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

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

Solution (Python):
k, s = map(int, input().split())
count = 0
for ai in range(k+1):
    remain = s - ai
    if remain > k * 2 or remain < 0:
        continue
    if remain <= k:
        count += remain + 1
    else:
        count += k * 2 - remain + 1
print(count)

Solution (Python):
row = input().split()
K = int(row[0])
S = int(row[1])
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 = [int(n) for n in input().split()]
print(sum([1 for X in range(K+1) for Y in range(K+1) if 0<=S-X-Y<=K]))

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

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

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

    pattern = 0

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

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    print(pattern)


if __name__ == "__main__":

    main()

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 z >= 0 and z <= k:
            c += 1
print(c)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

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

K, S = list(map(int, sys.stdin.readline().split()))

a = np.array(np.meshgrid(np.arange(K + 1), np.arange(K + 1))).sum(axis=0)
print(((S - K <= a) & (a <= S)).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 <= k and 0 <= z:
            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 - y - x
        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):
    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):
    z = s - x - y    
    if (y <= k and z <= k) and (0 <= z):  
      count+=1
      
print(count)

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

Solution (Python):


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

ccc = 0

for i in range(S+1):
    
    if i>K:
        break
    

    for j in range(S-i+1):
        
        
        
        
        if (j<=K) and (S - i - j <= K):
            ccc += 1
        
print(ccc)

Solution (Python):
K,S = map(int,input().split())
one = 0
three = 0
six = 0
if S%3==0:
    one = 1
else:
    one = 0
for l in range(K+1):
    if (S-l)%2==0 and (S-l)//2 <= K and (S-l)>=0:
        three += 1
for m in range(K-1):
    for n in range(m+1,K):
        rest = S-(m+n)
        if rest>n and rest<=K:
          six += 1
print(one+3*(three-one)+6*six)

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

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

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

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

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

Solution (Python):



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)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

K, S = LI()

count = 0
for x in range(K+1):
    for y in range(K+1):
        if (x+y <= S) and (x+y >= S-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 z >= 0 and z <= 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 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(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())
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 = [ int(v) for v in 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(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())
cnd = range(0, k+1)
print(str(sum([1 for x in cnd for y in cnd if s-x-y in cnd])))

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

Solution (Python):
p=input().rstrip().split(' ')
k=int(p[0])
s=int(p[1])
G=0;
for i in range(0,k+1):
    for j in range(0,k+1):
        b=s-(i+j)
        if b>=0 and b<=k:
            if (i+j+b)==s:
                G+=1;
print(G)

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

K, S = nl()

count = 0
for k1 in range(K+1):
    for k2 in range(K+1):
        k3 = S - (k1 + k2)
        if k3 >= 0 and k3 <= K:
            count += 1

print(count)

Solution (Python):
a = list(map(int,input().split()))
k = a[0]
s = a[1]
num=0
for l in range(k+1):
    for m in range(k+1):
        n = s-l-m
        if(n <= k and n >= 0):
            num+=1

print(num)

Solution (Python):
inputs= list(map(int,input().split()))
k = inputs[0]
s = inputs[1]
answer = 0
for i in range(k+1):
  x = i
  for l in range(k+1):
    y = l
    z = s-x-y
    if z >= 0 and z <= k :
      answer += 1
print(answer)

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:
            break
        if (S - x - y) <= K:
            ans += 1

print(ans)

Solution (Python):
inputs= list(map(int,input().split()))
k = inputs[0]
s = inputs[1]
answer = 0
for i in range(k+1):
  x = i
  for l in range(k+1):
    y = l
    z = s-x-y
    if z >= 0 and z <= k :
      answer += 1
print(answer)

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

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

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

Solution (Python):
K, S = map(int, input().split())
l = [i for i in range(K+1)]
cnt = 0
for i in l:
    if i > S:
        break
    elif i == S:
        cnt += 1
        break
    elif i < S:
        tmp1 = S-i
        if K-tmp1 >= 0:
            cnt += tmp1 + 1
        else:
            tmp2 = 2*K + 1 - tmp1
            if tmp2 > 0:
                cnt += tmp2
                
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 0<= S - i - j <= K:
        count += 1
      
print(count)

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

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())
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if S-sum>=0 and S-sum<=K :
            count+=1
            
        sum=a 
    sum=0
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 ((s-x-y) <= k) and ((s-x-y) >= 0) :
            
            count += 1

print(count)

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

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

K, S = list(map(int, sys.stdin.readline().split()))

ans = 0
for x in range(K + 1):
    yz = S - x
    if yz < 0 or 2 * K < yz:
        continue
    ans += yz + 1
    ans -= max(0, yz - K) * 2
print(ans)

Solution (Python):
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 y>s:
            break
        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(min(k+1,s+1-x)):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)

Solution (Python):
from sys import stdin

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

input = lambda: stdin.readline()
main()

Solution (Python):
K,S=(int(x) for x in input().split())
if(3*K<S):
    print("0")
else:
    count=0
    for i in range(K+1):
        for j in range(K+1):
            if(S-i-j<K+1 and 0<=S-i-j):
                count+=1

    print(count)

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

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)