Problem:
 Score : 200 points    Problem Statement You are given two integers K and S . Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K . How many different assignments of values to X, Y and Z are there such that X + Y + Z = S ?      Constraints  2≤K≤2500   0≤S≤3K   K and S are integers.         Input The input is given from Standard Input in the following format:  K  S       Output Print the number of the triples of X, Y and Z that satisfy the condition.        Sample Input 1 2 2      Sample Output 1 6  There are six triples of X, Y and Z that satisfy the condition:   X = 0, Y = 0, Z = 2   X = 0, Y = 2, Z = 0   X = 2, Y = 0, Z = 0   X = 0, Y = 1, Z = 1   X = 1, Y = 0, Z = 1   X = 1, Y = 1, Z = 0        Sample Input 2 5 15      Sample Output 2 1  The maximum value of X + Y + Z is 15 , achieved by one triple of X, Y and Z .

Solution (Python):
k, s = [int(_) for _ in input().split(' ')]
answer = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z and z <= k:
            answer += 1
print(answer)

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

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

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

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

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

result = 0
for X in range(K+1):
    for Y in range(K+1):
        Z = S-X-Y
        if Z<0:
            continue
        elif K<Z:
            continue
        elif S == X+Y+Z:
            result += 1
print(result)

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

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

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

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

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

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

Solution (Python):
K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
    n = S - i
    if i <= S and n <= K * 2:
        a = (n + 1) - max(0, n - K) * 2
        ans += a
print(ans)

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

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

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

cnt = 0

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

print(ans)

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

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

print(count)

Solution (Python):
K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    remainder = S - x
    if remainder < 0:
        break
    elif remainder > K * 2:
        continue
    else:
        ans += remainder + 1 - 2 * max(remainder - K, 0)
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=[int(i) for i in input().split()]
ans=0
for a in range(k+1):
  for b in range(a+1):
    if 0<=s-a-b<=b:
      l=len(set([a,b,s-a-b]))
      if l==1:
        ans+=1
      elif l==2:
        ans+=3
      else:
        ans+=6
print(ans)

Solution (Python):
def getinputdata():

    array_result = []
    
    data = input()
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()


k = int(arr_data[0][0])


s = int(arr_data[0][1])

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

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

for x in range(K+1):
    rem = S - x
    if rem < 0: break
    if rem > 2*K: continue
    for y in range(K+1):
        z = rem - y
        if z < 0: break
        if z > K: continue
        ans += 1
print(ans)

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

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

print(num)

Solution (Python):
from sys import stdin

K, S = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

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

Solution (Python):

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

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

print(count)

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

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

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

    print(comb)


if __name__ == '__main__':
    main()

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

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

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

cnt = 0

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

print(cnt)

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

Solution (Python):
K, S = [int(elem) for elem in 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 = [int(elem) for elem in 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())

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

Solution (Python):

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

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

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

print cnt

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

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

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

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

print(count)

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

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

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





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

Solution (Python):
data = list(map(int,input().split()))
cou = 0
for i in range(data[0] + 1):
  for j in range(data[0] + 1):
    k = data[1] - i - j
    if 0 <= k and k <= data[0]:
      cou += 1
print(cou)

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys

stdin = sys.stdin
na = lambda: list(map(int, stdin.readline().split()))

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

print(count)

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

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

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

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

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 = [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 0<=Z<=K:
      ans += 1
print(ans)

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

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

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

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

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

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

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

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

Solution (Python):
def main():
    """
    2 <= K <= 2500
    0 <= S <= 3K = 7500
    0 <= X,Y,Z <= K
    X+Y+Z=S

    2500**3: 15625 * (10^6) => 1.5625 * (10^10)
    Z = S - x - y
    x * y: 2500^2
    """
    K, S = map(int, input().split())

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

    print(ans)

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

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

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

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


if __name__ == "__main__":
    main()

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

print(count)

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

count = 0

if K>S: n=S
else: n=K
x=0
for i in range(n+1):
	if K>S-x: m=S-x
	else: m=K
	y=0
	for j in range(m+1):
		if S-x-y<=K: count +=1
		y+=1
	x+=1

print(count)

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

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


if __name__ == "__main__":
    main()

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

ans = 0

if k < s <= 2*k:
    for i in range(k+1):
        ans += min(2*k-s+i, s-i)+1
else:
    ans = sum(range(min(3*k-s, s)+2))

print(ans)

Solution (Python):
k,s=[int(i) for i in input().split()]
count = 0
for y in range(k+1):
 if y < s - k * 2 or s - y < 0:
  continue
 for x in range(k+1):
   if s - x - y >= 0 and s - x - y <= k:
      count = count+1
print(count)

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

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

print(ret)

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

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

C=0

X=0
Y=0


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

print(C)

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

print(count)

Solution (Python):
input_line = map(int,raw_input().split(" "))
K = input_line[0]
S = input_line[1]
count = 0
for k in range(K+1):
	for kk in range(K+1):
		X = S - kk - k
		if 0 <= X <= K:
			count += 1

print count

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

print(cnt)

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

count = 0

for 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):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

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

Solution (Python):
from collections import defaultdict


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


if __name__ == '__main__':
    main()

Solution (Python):
K,S = map(int,input().split())
ans = 0
for x in range(max(0,S-2*K), K+1):
    rest = S - x
    y_min = max(0, rest-K)
    for y in range(y_min, K+1):
        z = rest - y
        if z <= K and z >= 0:
            ans += 1

print(ans)

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

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

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

Solution (Python):
import sys




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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


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


main()

Solution (Python):


import sys
import subprocess
import json
import time
import math
import re
import sqlite3

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

ans = 0
for x in range(0, K+1):
  for y in range(0, K+1):
    z = S - x - y
    if z <= K and z >= 0:
      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 S-X-Y>=0 and S-X-Y<=K:
            count+=1

print (count)

Solution (Python):
a = input().split()
k = int(a[0])
s = int(a[1])
count = 0
for n1 in range(k+1):
    for n2 in range(k+1):
        if 0<=(s - n1 - n2)<=k:
            count += 1

print(count)

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

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

count = 0
m = K + 1


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

print(count)

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

Solution (Python):
k,s = map(int, raw_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, raw_input().split())
ans = 0
for X in xrange(0, K + 1):
    for Y in xrange(0, min(K + 1, S - X + 1)):
        if 0 <= S - (X + Y) <= K:
            ans += 1
print ans

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

print(ans)

Solution (Python):



def main():
    k, s = map(int, input().split())
    answer = solve(k, s)
    return answer


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

print(main())

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

if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import defaultdict


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


if __name__ == '__main__':
    main()

Solution (Python):

INF=10**10

def main():
    
    k,s=list(map(int,input().split()))
    sum=0
    for i in range(k+1):
        for j in range(k+1):
            if s-(i+j)>=0 and s-(i+j)<k+1:
                sum+=1
    print(sum)
    
if __name__=="__main__":
    main()

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

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

for x in range(K + 1):
    S2 = S - x
    if S2 < 0:
        break
    elif S2 > 2*K:
        continue
    else:
        cnt += (S2 + 1) - 2*max(0, S2 - K)

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

print(cnt)

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

Solution (Python):
ks = list(map(int, input().split()))
K = ks[0]
S = ks[1]

c = 0

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

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):
from itertools import product as prod

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

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

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

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

print(a)

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

c = 0
for x in range(S//3 + 1):
    for y in range(x, (S-x)//2 + 1):
        z = S - (x + y)
        if z <= K:
            l = len(set((x,y,z)))
            if l == 1: c += 1
            elif l == 2: c += 3
            else: c += 6
print(c)

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

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

ls = [i for i in range(k+1)]

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

Solution (Python):

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

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

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

print(ans)

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

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

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

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

print(cnt)

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

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