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):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
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_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


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

if __name__=="__main__":
    main()

Solution (Python):
k,s=map(int,input().split())
dp=[0]*(3*k+4)
dp[0]=1
dp[k+1]=-3
dp[2*k+2]=3
dp[-1]=-1
from itertools import accumulate
dp=list(accumulate(list(accumulate(list(accumulate(dp))))))
print(dp[s])

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



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


if __name__ == "__main__":
    main()

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

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

Solution (Python):



def main():
    K, S = map(int, open(0).read().split())
    
    
    
    
    
    
    print(
        len(
            [
                0
                for X in range(K + 1)
                for Y in range(S - X + 1)
                if (Y <= K) & (S - X - Y <= K)
            ]
        )
    )


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

print(count)

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

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

cnt = 0
for x in range(0,K+1):
  if x > S:
    continue
  for y in range(0,K+1):
    if x+y > S:
      continue
    elif x+y+K < S:
      continue
    else:
      cnt +=1
        
print(cnt)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


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

for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if 0 <= l <= k:
            cnt += 1
            
print(cnt)

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

count=0

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

print(count)

Solution (Python):
K,S = map(int,input().split())
x = y = S//3
z = S - x - y
if z < y:
    x = z
    z = y
ans = 0
while 0 <= x <= y and 0<= y <=K and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
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 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(K+1):
    for y in range(K+1):
        a = S-x-y
        if a <= K and a >= 0:
            ans +=1
print(ans)

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

Solution (Python):
K,S = (int(x) for x in input().split())
count = 0
for x in range(K+1):
  for y in range(K+1):
    remain = S-x-y
    if 0 <= remain and remain <= 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())
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 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())

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

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())
ret = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            ret += 1


print(ret)

Solution (Python):


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


print(ret)

Solution (Python):


K, S = map(int, input().split())
AB = []
ret = 0
for i in range(K+1):
    for j in range(K+1):
        AB.append(i+j)

for i in range(len(AB)):
    if 0 <= S - AB[i] <= K:
        ret += 1

print(ret)

Solution (Python):


K, S = map(int, input().split())
AB = []
ret = 0
for i in range(K+1):
    for j in range(K+1):
        AB.append(i+j)

for i in range(len(AB)):
    if 0 <= S - AB[i] <= K:
        ret += 1

print(ret)

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

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

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

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

ans = 0

for x in range(max(0, S - 2 * K), min(K, S) + 1):
    ans += min(K, S - x) - max(0, S - x - K) + 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 + 1:
			ans += 1

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

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

ans = 0

for i in range(K+1):
	for j in range(K+1):
		if S-K<=i+j<=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):
    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):
    if 0 <= S-X-Y <= K : count += 1
print(count)

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

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

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

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

Solution (Python):


def g(s, k):
	if s < 0: return 0
	if s == 0: return 1
	if k <=s <= 2*k: 
		return k - (s - k) +1
		return k +1
	if s < k: return s + 1
	if s > 2*k: return 0 

def f(s,k):
	ans = 0
	for c in range(k+1): 
		ans += g(s - c,k)
	return ans
k,s = map(int, raw_input().split())
print f(s,k)

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

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(k+1):
    for j in range(i, k+1):    
        if 0 <= s-i-j <= k and j <= s-i-j:
            if i == j == s-i-j:
                ans1 +=1
            elif i == s-i-j or i == j or j == s-i-j:
                ans2 += 1
            else:
                ans3 += 1
                    

print(ans1+ans2*3+ans3*6)

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

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

Solution (Python):
K,S = (int(T) for T in input().split())
Count = 0
for TX in range(0,K+1):
    for TY in range(0,K+1):
        if 0<=(S-TX-TY)<=K:
            Count += 1
print(Count)

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

if k > s:
    k = s

ans = 0
for x in range(k+1):
    rem = s - x
    if rem > 2 * k:
        continue
    elif rem > k:
        ans += 2 * k - rem + 1
    else:
        ans += rem + 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 (((s-x-y) <=k) and (0 <= (s-x-y))):
            count +=1
print(count)

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

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

Solution (Python):

k, s = map(int, input().split())
if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    ans = ((k + 1) * (k + 2) / 2) - ((2 * k - s) * ((2 * k - s) + 1) / 2) + (t * (2 * k - ((2 * k - s) - 1)) / 2)
elif s <= 3 * k:
    ans = (3 * k - s + 1) * ((3 * k - s + 1) + 1) / 2
print(int(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

if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    a = (k + 1) * (k + 2) / 2
    b = t * (t + 1) / 2
    c = t * (2 * k - (t - 1)) / 2
    ans = a - b + c
elif s <= 3 * k:
    t = 3 * k - s + 1
    ans = t * (t + 1) / 2
print(int(ans))

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

print(cnt)

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

minz = max(0, s-2*k)
maxz = min(s, k)

def f(s, k):
    if k >= s:
        return (s+1)
    else:
        return (2*k-s)+1

ans = 0
for i in range(minz, maxz+1):
    ans += f(s-i, k)

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
input = sys.stdin.readline
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - x - y <= K:
            ans += 1
print(ans)

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

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

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


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

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

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

print(ans)

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

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=c+1
print(c)

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

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

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

Solution (Python):

def main():
    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
    else:
        print(cnt)



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

print(count)

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

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

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

Solution (Python):







def solve(k,s):
  res = 0
  for i in range(k+1):
    for j in range(k+1):
      l = s - i - j
      if 0 <= l <= k:
        res += 1

  return res



def main():
  K,S = map(int,input().split())
  
  print(solve(K,S))
  return

if __name__ == '__main__':
  main()

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

Solution (Python):
k,s = map (int ,input ().split ())
x = 0
y = 0
p = 0
while x <= k:
  while y <= k:
    if x+y > s:
      break
    z = s-(x+y)
    if 0 <= z <= k:
      p += 1
    y += 1
  x += 1
  y = 0
print (p)

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

print(ans)

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)  
    if z>k or z<y:
      continue
    if x == y and y == z: 
      ans+=1
    elif x==y or y == z or z==x:
      ans+=3
    else:
      ans+=6


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



import sys
from io import StringIO
import unittest


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

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

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


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)


if __name__ == "__main__":
    
    resolve()

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

print(ans)

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

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

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= 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):
        N = S - (x+y)
        if 0<= N <= 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 = map(int, input().split())
	cnt = 0

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

	print(cnt)

  
if __name__ == "__main__":
  	main()

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

for i in range(k+1):
    if i <= s:
        for j in range(k+1):
            if i+j<=s:
                if 0<=s-i-j<=k:
                    cnt+=1
print(cnt)

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

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

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

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

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

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

Solution (Python):
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 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:
            n += 1

print(n)

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
else:
    print(ans)

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

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

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

print(ans)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

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

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


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

print(counter)

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

Solution (Python):
K, S = list(map(lambda n: int(n), input().split(" ")))
cnt = 0

for x in range(K + 1):
  if S - x > 2 * K:
    continue
  for y in range(K + 1):
    if 0 <= S - x - y <= K:
      cnt += 1

print(cnt)

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

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

Solution (Python):

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

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

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

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

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

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

Solution (Python):
splited = input().split(" ")

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

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

print(result)

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 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 x in range(k+1):
    w=s-x
    if w>=0:
        for y in range(k+1):
            v=w-y
            if k>=v>=0:
                count=count+1
            else:
                pass
    else:
        pass
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())
res=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=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 (z>=0 and z <= k and x+y+z == s):
            
            ans += 1
print(ans)

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

if __name__ == "__main__":
    main()

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

Solution (Python):
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

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

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

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

print(ans)

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

l = max(S-K*2, 0)
h = min(K, S)

res = 0
for i in range(l, h+1):
    x = S-i
    ll = max(x-K, 0)
    hh = min(h, x)
    res += hh-ll+1

print(res)

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

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

Solution (Python):
x = list(map(int, input().split()))
cnt = 0
for i in range(x[0]+1):
  for j in range(x[0]+1):
    p = i+j
    if (p <= x[1]) and (x[0]+p) >= x[1]:
      cnt += 1
print(cnt)

Solution (Python):
K,S=map(int,input().split())
R=range(0,K+1)

W=0
for X in R:
    for Y in R:
        Z=S-(X+Y)
        W+=(0<=Z<=K)
print(W)

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

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

print(ans)

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

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

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

print(cnt)