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

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

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

print(count)

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

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

print(count)

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

s = 0

X = max(0,S-2*K)
while X <= min(K,S):
    s += min(K,S-X) - max(0,S-X-K) + 1
    X += 1

print(s)

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

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

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

Solution (Python):
def f(K, S):
    
    res = 0
    for i in range(K+1):
      for j in range(K+1):
        if i + j <= S and S-i-j <= K:
          res += 1
    return res

inx = list(map(int, input().split()))
print(f(inx[0], inx[1]))

Solution (Python):



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

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

print(cnt)

Solution (Python):
a, b = (int(i) for i in input().split())  
print(sum([min(2*a+i-b+1,b-i+1) for i in range(a+1) if min(2*a+i-b+1,b-i+1) > 0]))

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

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

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

print(count)

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

print(count)

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

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

print(count)

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

Solution (Python):

k, s = (int(_) for _ in input().split())
done = []
if s == 3*k:
    print(1)
else:
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            remainder = s - i - j
            if 0 <= remainder <= 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):
        Z = S - j -i
        if 0 <= Z <= K:
            count += 1
print(count)

Solution (Python):

k, s = list(map(int, input().rstrip().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()))
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):
        if K >= S-X-Y >= 0:
            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())
c=0
for i in range(0,k+1):
  for j in range(0,k+1):
    if i+j+k<s:
      pass
    elif i+j>s:
      pass
    else:
      c+=1
print(c)

Solution (Python):
K, S = input().strip().split()
K, S = [int(K), int(S)]

A = 0
for x in range(K+1):
  for y in range(K+1):
    if S - x - y <= K and S - x - y >= 0:
      A = A + 1

print(A)

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

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


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

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

k += 1

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

print(ans)

Solution (Python):


def read_input():
    k, s = map(int, input().split())

    return k, s


def check_z(z, k):
    if z <= k:
        return z
    else:
        return -1


def check_yz(y, k):
    count = 0
    tempy = min(y, k)
    while tempy >= 0:
        if check_z(y - tempy, k) != -1:
            count += 1
        tempy -= 1
    return count

def check_xyz(x, k):
    count = 0
    tempx = min(x, k)
    while tempx >= 0:
        yc = check_yz(x - tempx, k)
        if yc != -1:
            count += yc
        tempx -= 1
    return count



def submit():
    k, s = read_input()

    print(check_xyz(s, k))

if __name__ == '__main__':
    submit()

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

cnt = 0

if S <= 0:
  cnt += 1
else:

  if K >= S:
      cnt+=3

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

  cnt+=3*cnt2(K, S)

  for x in range(1, K+1):
      if S-x <=0:
          break
      cnt += cnt2(K, S-x)

print(cnt)

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

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

sum=0

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

print(sum)

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

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

print(count)

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

print(res)

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

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

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

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

num = 0
for x in range(sk[0] + 1):
	for y in range(sk[0] + 1):
		if x + y <= sk[1] and sk[1] - x - y <= sk[0]:
			num += 1
        

print(num)

Solution (Python):
import numpy as np


A = list(map(int, input().split()))
K = A[0]
S = A[1]
counter = 0
for i in range(K+1):
	for j in range(K+1):
		sa = S - (i + j)
		if 0 <= sa and sa <= K:
			counter = counter + 1
			
			
print(counter)
print("\n")

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

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

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

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

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

print(ans)

Solution (Python):
K, S = map(int, input().split())
print(sum(map(lambda x: K+1-abs(K-S+x) if 0<=S-x<=K*2 else 0 , [i for i in range(K+1)])))

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

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

count = 0
for x in Xs:
    yz = S - x
    if 0 <= yz  <= K*2:
        count += K+1-abs(K-yz)
    
print(count)

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

Xs = [i for i in range(K+1)]
Ys = Xs[:]

count = 0
for x in Xs:
    for y in Ys:
        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 0<=z and z<=k:
          cnt+=1
print(cnt)

Solution (Python):

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


c=0

for X in range(K+1):
  for Y in range(K+1):
    Z=S-(X+Y)

    if Z>=0 and Z<=K:
      c+=1


print(c)

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

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

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

Solution (Python):
import itertools

k, s = map(int, input().split())
ans = 0
for x, y in itertools.product(range(k + 1), repeat=2):
    z = s - x - y
    if 0 <= z <= k:
        ans += 1

print(ans)

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

ans=0

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

Solution (Python):

k,s=map(int,input().split())
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):
import sys
input=sys.stdin.readline
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):


l = list(map(int,input().split()))	
K = l[0]
S = l[1]
count = 0
for i in range(K + 1):
    X = i
    if X > S:
        break
    for j in range(K + 1):
        Y = j
        if X + Y > S:
            break
        else:
            Z = S - (X + Y)
            if Z <= K:
                count += 1

print(count)

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

Solution (Python):
K, S = map(int, input().split())
num = 0
for X in range(K + 1):
    for Y in range(min(K, S - X) + 1):
        Z = S - X - Y
        if Z < 0:
            break
        if K < Z:
            continue
        num += 1
print(num)

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

Solution (Python):
K, S = map(int, input().split(' '))
count = 0
for x in range(K+1):
    t1 = S - x
    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, z = 0, 0, 0
c = 0
for i in range(K + 1):
    if S - i > 2 * K:
        continue
    for j in range(K + 1):
        if i + j > S:
            break
        elif S - i - j > K:
            continue
        c += 1
print(c)

Solution (Python):
from itertools import product

n, s = map(int, (input().split()))
ans = 0

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

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

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

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

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

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

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

c = 0

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

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

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

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

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

true=0

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

print(true)

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())
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())
number = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if 0 <= z <= K:
      number += 1
print(number)

Solution (Python):
if __name__ == '__main__':
    ks = input()
    k, s = [int(i) for i in ks.split()]

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

    print(c)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K, S = MAP()
ans = []
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 = [int(item) for item in input().split()]
ans = 0
for x in range(0,k+1):
    for y in range(0,k+1):
        if x + y <= s and 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())
cnt = 0
for l in range(k+1):
    for m in range(k+1):
        if l+m<=s and s-l-m<=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):
import sys

def main():
    input = sys.stdin.readline
    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

    return ans


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

print(ans)

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

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

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

Solution (Python):
def count(k, s):
    answer = 0

    for a in range(s + 1):
        if a > k:
            
            break

        if s - a > 2*k:
            continue

        for b in range(a, s + 1):
            x = a - 0
            y = b - a
            z = s - b

            if y > k:
                break

            if z <= k and x + y + z == s:
                answer += 1

    return answer

k, s = map(int, input().split())
print(count(k, s))

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

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

print(counter)

Solution (Python):


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

ans=0

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

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

num = 0
for x in range(K+1):
    for y in range(K+1):


        if 0 <= S - x- y <= K:
            num += 1
                
print(num)

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

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

print(ans)

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())
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())
c = 0
for x in range(k+1):
    for y in range(k+1):
        if ((s-x-y) <= k) & ((s-x-y) >= 0):
            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 (S - (x + y) <= K) and (0 <= S - (x + y)):
            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 0<=Z and Z<=K:
            ans +=1


print(ans)

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

count = 0
for x,y in itertools.product(range(0,K + 1),range(0,K + 1)):
    z = S - x - y
    if 0 <= z <= K:
        count += 1

print(count)

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

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

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

print(ans)

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

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

print(count)

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

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

print(count)

Solution (Python):
A=list(map(int,input().split()))
K=A[0]
S=A[1]
count=0
for a in range(K+1):
    for b in range(K+1):
        c=S-a-b
        if 0<=c<=K:
            count+=1
        else:
            continue
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(i+j<=s and s-(i+j)<=k):
        ans+=1
print(ans)

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

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

Solution (Python):

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

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

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

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

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

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


line = input()
line = line.split(" ")
k, s = int(line[0]), int(line[1])
counter = 0
for x in range(s // (3*k), min(s, k)+1):
    for y in range(s // (3*k), min(s, k)+1):
        if s - (x + y) < 0:
            break
        elif s - (x + y) <= k:
            counter += 1
print(counter)

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

Solution (Python):
def main(input_str):
    nums = list(map(int, input_str.split()))

    count = 0
    for num_1 in range(nums[0]+1):
        for num_2 in range(nums[0]+1):
            if 0 <= nums[1]-(num_1+num_2) <= nums[0]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

Solution (Python):
def main(input_str):
    nums = list(map(int, input_str.split()))

    count = 0
    for num_1 in range(nums[0]+1):
        for num_2 in range(nums[0]+1):
            if 0 <= nums[1]-(num_1+num_2) <= nums[0]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

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

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

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

Solution (Python):
from functools import reduce

def main():
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    K,S = (int(_) for _ in input().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):            
            if(K >= S - x - y and S - x - y >= 0):
                ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

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

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

Solution (Python):
k,s = map(int,input().split())
a = ((s+1)*(s+2))//2
b = ((s-k)*(s-k+1))//2
c = (((abs(s-k*3))+1)*((abs(s-k*3))+2))//2

if s <= k:
    print(a)
elif s <= k*2:
    print(a-b*3)
elif s <= k*3:
    print(c)

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

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

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

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

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

print(count)

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

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

for i in range(k+1):
    for j in range(k+1):
        if i+j <= s and s <= k+i+j:
            a += 1
        else:
            pass

print(a)

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

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

print(ans)

Solution (Python):
def sum_of_three_integers(K: int, S: int)->int:
    count = 0
    for x in range(K+1):
        for y in range(x, K+1):
            z = S - (x + y)

            if z < 0 or K < z:
                
                continue

            if z < y:
                
                break

            if x == y and y == z:
                
                count += 1
            elif x == y or y == z:
                
                count += 3
            else:
                
                count += 6
    return count


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

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

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

print(ans)