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())
res = 0
for x in range(K+1):
    y_z = S - x
    if y_z < 0:
        continue
    
    y_min = max(y_z-K,0)
    y_max = min(y_z,K)
    res += max(y_max-y_min+1,0)

print(res)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

K, S = MAP()

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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

K, S = MAP()

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 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):
import itertools
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 & 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 or z > k):
           continue
        ans += 1 
print(ans)

Solution (Python):
K,S=[int(x) for x in input().rstrip().split()]
cnt=0
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-(x+y) and S-(x+y)<=K:
      cnt+=1
print(cnt)

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())
c=0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z > k or z < 0:
            continue
        c += 1
print(c)

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

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

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

Solution (Python):
k, s = map(int, input().split())
"""
・Z=S-(X+Y)
・0<=Z<=K
"""
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s >= x + y >= s - k:
            ans += 1
print(ans)

Solution (Python):

def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

data = datain(2)
ans = 0

for x in range(data[0]+1):
    for y in range(data[0]+1):
        
        if data[0] >= data[1]-x-y >= 0:
            ans += 1

print(ans)

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

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

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

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

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

print(ans)

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

if '__main__' == __name__:
    resolve()

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):
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 0 <= z <= K:
            cnt += 1

print(cnt)

Solution (Python):
import math

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

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

Solution (Python):

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

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())
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 = [int(i) for i in 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())

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

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

K, S = map(int, sys.stdin.readline().split())
ans = 0
for i in range(K+1):
  for j in range(K+1):
    if S - i - j < 0:
      break
    elif S - i - j > K:
      continue
    else:
      ans += 1
print(ans)

Solution (Python):
class SumofThreeIntegers:
    def calculate(self, K, S):
        self.counter = 0
        for x in range(K+1):
            for y in range(K+1):
                z = S - x - y
                if z < 0 or K < z:
                    pass
                elif x + y + z == S:
                    self.counter += 1
        return self.counter
            
if __name__ == "__main__":
    K, S = map(int, input().split())
    sti = SumofThreeIntegers()
    res = sti.calculate(K, S)
    print(str(res))

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 a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt += 1
        
print(cnt)

Solution (Python):
line = input().split()
k =int(line[0])
s =int(line[1])
data =[0,0,0]
out =0

for i in range(k+1):
  for t in range(i,1+k):
    data[0] =i
    data[1] =t
    data[2] =s-data[1]-data[0]
    
    if data[2] >=0 and data[2] <=k and data[2]>=t :
     
      if data[0] ==data[1] and data[0] ==data[2] and data[1] ==data[2]:
        out +=1
      elif data[0] !=data[1] and data[0] !=data[2] and data[1] !=data[2]:
        out +=6
      else:
        out +=3
print(out)

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

Solution (Python):
K,S=map(int, input().split())
count = 0
for x in range(min([K+1,S+1])):
  for y in range(min([K+1,S+1-x])):
    if S-x-y<=K:
      count = 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):
        z = S - x - y
        if 0 <= z <= K:
            cnt += 1
print(cnt)

Solution (Python):
inf = 10**15
mod = 10**9+7
k,s = map(int, input().split())
ans = 0
for i in range(k+1):
    tmp = s-i
    if tmp >= 0:
        for j in range(k+1):
            t = tmp-j
            if 0 <= t <= 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 0 <= s - x - y <= k:
            cnt += 1
print(cnt)

Solution (Python):
K,S = map(int,input().split())
def main(K,S):
    if S > 3*K:
        print(0)
        
    else:
        count = 0
        for i in range(K+1):
            for j in range(K+1):
                if 0 <= S - i - j <= K:
                    count += 1
        print(count)
if __name__ == '__main__':
   main(K,S)

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

def main():
    K, S = map(int, readline().rstrip().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

def main():
    K, S = map(int, readline().rstrip().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import sys
import string
import time


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


def I():
    return int(input())


def S():
    return input()


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


def MS():
    return map(str, input().split())


def LI():
    return list(map(int, input().split()))


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


N = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


def main():
    K, S = MI()
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = x + y - S
            if -K <= z & z <= 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    k,s = readInts()
    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 x in range(k + 1):
    for y in range(k + 1):
        z = s - (x + y)
        if z <= k and z >= 0:
            
            ans += 1

print(ans)

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

x_list = list(range(K+1))
y_list = list(range(K+1))
ans = 0

for x in x_list:
    for y in y_list:
        if 0 <= S-x-y <= K:
            ans += 1
print(ans)

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10**5+10)

input = sys.stdin.readline

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 <=K and z>=0:
            cnt +=1

print(cnt)

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

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

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

Solution (Python):
def ABC051B(k, s):
    a = [0] * (3 * k + 1)
    mx = -(-3 * (k + 1) ** 2 // 4)
    for i in range(k + 1):
        a[i] = (i + 1) * (i + 2) // 2
        a[3 * k - i] = (i + 1) * (i + 2) // 2
    if k % 2 == 0:
        max_point = 3 * (k // 2)
        a[max_point] = mx
        odd_cum_diff = [x ** 2 for x in range(k // 2)]
        for j in range(k // 2):
            a[max_point - j] = mx - odd_cum_diff[j]
            a[max_point + j] = mx - odd_cum_diff[j]
    else:
        max_point = 3 * (k // 2) + 1
        a[max_point] = mx
        even_cum_diff = [x * (x + 1) for x in range(k // 2)]
        for j in range(k // 2):
            a[max_point - j] = mx - even_cum_diff[j]
            a[max_point + j + 1] = mx - even_cum_diff[j]
    
    
    print(a[s])

k, s = map(int, input().split())
ABC051B(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())
print(len([0 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())
print(len([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())
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):
        if 0<=S-X-Y<=K: 
            count += 1
print(count)

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

Solution (Python):
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
    y_min = max(S- x - K, 0)
    y_max = min(S - x, K)
    ans += max(0, y_max - y_min + 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(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())

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

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

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

Solution (Python):
m,n=map(int,input().split())
ans=0
for i in range(m+1):
  for j in range(m+1):
    if 0 <= n-i-j <= m:
      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())
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):
from sys import stdin


[K, S] = list(map(int, stdin.readline().rstrip().split()))

count=0

for x in range(K+1):
    for y in range(K+1):
        if x + y > S:
            continue
        if S - (x + y) <= K:
            
            count = count + 1

print(count)

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

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

    return count

print(fun(k, s))

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())
l=[]
for x in range(0, k+1):
    for y in range(0, k+1):
        if s-x-y > k or s-x-y < 0:
            continue
        else:
            l.append(s-x-y)
print(len(l))

Solution (Python):
k,s=map(int,input().split())
count=0
if s%3==0:
    count+=1
for i in range(0,s//2+1):
    if 0<=s-2*i<=k and i<=k and s-2*i!=i:
        count+=3
for i in range(0,k-1):
    for j in range(i+1,k):
        if k>=s-i-j>j:
            count+=6
print(count)

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

Solution (Python):
k,s = map(int,input().split())
n = 3*k-s
ans = 0
if n == 0:
  ans = 1
elif n<0:
  None
else:
  for i in range(min(k,n),min(k-1,(n-1)//3),-1):
    t = min(k,n-i,i)
    for j in range(t,min(t-1,(n-i-1)//2),-1):
      l = n-i-j
      if i!= j and j != l:
        ans += 6
      elif i == j == l:
        ans += 1
      else:
        ans += 3
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 0 <= 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 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(x, k+1):
        z = s - x - y
        l = {x, y, z}
        if y <= z <= k:
            if len(l) == 3:
                ans += 6
            elif len(l) == 2:
                ans += 3
            else:
                ans += 1

print(ans)

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

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

Solution (Python):
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
                if K >= S - (x + y) >= 0 :
                    count += 1
                    
    print(count)

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

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

print(cnt)

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

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


print(count)

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

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

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 i in range(K + 1):
  for j in range(K + 1):
    if S >= i + j >= S - 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 0<=S-X-Y and 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):
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

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

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

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


ans=0
for x in range(k+1):
  if s-x<0:
    break
  a=max(0,s-x+1)
  a-=max(0,(s-x-k)*2)
  ans+=max(0,a)
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())
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())
i = 0
for x in range(k+1):
    for y in range(k+1):
        if k < s-x-y or s-x-y < 0:
            continue
        i += 1

print(i)

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):
def solve(K, S):
    count = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S - i - j <= K:
                count += 1
    return count
def main():
    K, S = map(int, input().split())
    count = solve(K, S)
    print(count)
main()

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

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

Solution (Python):





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

if s == 0 or s == 1:
    print(1)
    exit()

if s <= k:
    print((s+2)*(s+1)//2)
    exit()











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

Solution (Python):
def resolve():
    K, S = map(int, input().split())
    count = 0
    for x in range(K + 1):
        for y in range(max(0, S - K - x), min(K + 1, S - x + 1)):
            count += 1
    print(count)


if __name__ == "__main__":
    resolve()

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


if __name__ == "__main__":
    resolve()