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

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

count = 0

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

print(count)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    k, s = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(k + 1):
        for j in range(k + 1):
            n = s - i - j
            if 0 <= n <= k:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

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

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

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

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

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


OK = 0
for x in range(K+1):
    if(0<=S-x & S-x<=2*K): 
        if(S-x<=K): 
            OK += S-x+1
        else: 
            OK += (K-((S-x)-K))+1
print(OK)

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


def calc_xyz(target, limit):
    cnt = 0
    for x in range(min(limit, target) + 1):
        yz_sum = target - x
        for y in range(min(limit, yz_sum) + 1):
            if 0 <= target - x - y <= limit:
                cnt += 1
    return cnt


print(calc_xyz(s, k))

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

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    k, s = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if i + j > s:
                break
            else:
                n = s - i - j
                if 0 <= n <= k:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

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

Solution (Python):
k, s = map(int, input().split())
result = [i_1+i_2 for i_1 in range(k+1) for i_2 in range(k+1) if 0<=s-i_1-i_2<=k]
print(len(result))

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):
def f(K, S):
    num=0
    for a in range(K+1):
      if S-a>=0 and S-a<=2*K:
        if S-a<=K:
          num+=S-a+1
        else:
          num+=(K-((S-a)-K))+1
    return num

  
K,S=(int(x) for x in input().split())
print(f(K,S))

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

for x in range(k+1):
    if s-x > 2*k:
        continue
    for y in range(k+1):
        if s-x-y > k or s-x-y < 0:
            continue
        else:
            counter += 1
            
print(counter)

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

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

print(res)

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

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

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

print(cases)

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

count = 0

for i in range(K+1):
    x = i
    for j in range(min(K+1,S-x+1)):
        y = j
        z = S-x-y
        if x + y + z == S and z <= K:
            count += 1

print(count)

Solution (Python):
import sys

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

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

print(ans)

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

for i in range(K + 1):
    if i > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

print(ans)

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

for i in range(K + 1):
    s = i
    if s > S:
        break
    for j in range(K + 1):
        s = i + j
        if s > S:
            break
        Z = S - s
        if 0 <= Z <= K:
            ans += 1

print(ans)

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

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

for x in range(K+1):
  if K<S-x<=2*K:
    a+=2*K-S+x+1
  elif 0<=S-x<=K:
    a+=S-x+1
  else:
    a+=0

print(a)

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

Solution (Python):
def main():
    k, s = map(int, input().split())
    if s > 3*k:
        pass
    elif s == 3*k:
        ans = 1
    else:
        ans = 0
        for i in range(k+1):
            for j in range(k+1):
                    if 0<=s - (i + j)<=k:
                        ans += 1
    print(ans)
main()

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

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

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
k,s=map(int,input().split())
cnt=0

for i in range(k+1):
	a=i
	for j in range(k+1):
		b=j
		if a+b<=s and a+b+k>=s:
			cnt+=1
			
print(cnt)

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

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

print(cnt)

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

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

Solution (Python):
K,S = map(int,input().split())
x = 0
for i in range(K+1):
    if S-i > 2*K:
        continue
    else:
        for l in range(K+1):
            if S-i-l > K or i+l > S:
                continue
            else:
                x += 1
print(x)

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

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

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

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

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

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

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

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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

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

count = 0

x = 0
while (x <= K):
    y = 0
    while (y <= K):
        if 0 <= S - (x + y) <= K:
            count += 1
        y += 1
    x += 1



print(count)

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

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

if __name__ == "__main__":
    SumofThreeIntegers()

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

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

Solution (Python):
import sys

data=input().split(' ')
k=int(data[0])
data_1sub=k+1
s=int(data[1])
d=0
e=0
for i in range(data_1sub):
    for j in range(data_1sub):
        d=s-i-j
        if (0 <= d) and (d <= k):
            e=e+1
        else:
            pass
print(e)

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

print(len(ans))

Solution (Python):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
k, s = na()

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

def main():
    K, S = tuple(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:
                break
            if 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):
        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
else:
    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):
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    yz = S - x
    if yz < 0:
        break
    elif yz <= K:
        count += yz + 1
    elif yz <= 2*K:
        count += K - (yz-K) + 1
print(count)

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

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

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

Solution (Python):
k, s = map(int, input().split())
if 0 <= s <= k:
    ans = (s+1)*(s+2)/2
    print(int(ans))
elif k < s <= 2*k:
    ans = ((s+1)*(s+2)/2) - ((s-k)*(s-k+1)/2) - ((s-k)*(s-k+1))
    print(int(ans))
elif 2*k < s < 3*k:
    print(3)
else:
    print(1)

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


if 0 <= S <= K:
    print(int((S+1)*(S+2)/2))
elif K < S <= 2*K:
    print(int((K+1)**2 - (2*K-S)*(2*K-S+1)/2 - (S-K)*(S-K+1)/2))
else:
    print(int((3*K-S+1)*(3*K-S+2)/2))

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


ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if S-K <= X+Y <= S:
            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 z >=0 and s<=3*k and z<=k:
            cnt +=1
print(cnt)

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

Solution (Python):
K, S = map(int, input().split())
t = S - K
r = S - 2*K
if t <= 0:
    answer = (S+2)*(S+1)/2
elif r <= 0:
    answer = (S+2)*(K-t+1)/2 + (S*2-t*3+1)*t/2
else:
    answer = (3*K-S+2)*(3*K-S+1)/2
    
print(int(answer))

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

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

Solution (Python):
import sys



lines = [x.strip() for x in sys.stdin.readlines()]

def slv(lines):
    ans = 0
    s = int(lines[0].split()[1])
    k = int(lines[0].split()[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
            
    return ans

if __name__ == "__main__":
    print(slv(lines))

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

ans = 0
for a in range(K+1):
  for b in range(K+1):
    c = A-(a+b)
    if 0 <= c <= K:
        ans += 1

print(ans)

Solution (Python):
k,s = [int(i) for i in input().split()]
ans = 0
for a in range(k+1):
    for b in range(k+1):
        c = s - a -b
        if  0 <= c <= 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(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 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())

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

print(count)

Solution (Python):
K, S=map(int, input().split())
KK=2*K
counter=0
for x in range(K+1):
  yz=S-x
  if yz<0:
    pass
  else:
    if yz<=K:
      counter+=(yz+1)
    elif yz>KK:
      pass
    else:
      counter+=(KK-yz+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 S-x-y>=0 and S-x-y<=K:
      ans+=1
print(ans)

Solution (Python):






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





count = 0





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


print(ans)

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 sys
input = sys.stdin.readline

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

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



if __name__ == "__main__":
    main()

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

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

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());print(sum(0<=S-X-Y<=K for X in range(K+1)for Y in range(K+1)))

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

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

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

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




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

print(count)

Solution (Python):
a = list(map(int,input().split()))
c=0
for i in range(a[1]-2*a[0] if a[1]-2*a[0] > 0 else 0, a[0]+1):
    for j in range((a[1]-i)-a[0] if (a[1]-i)-a[0] > 0 else 0, a[0] + 1):
        if i + j <= a[1]:
            c += 1

print(c)

Solution (Python):
import math

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

ans = 0
for i in range(min(s + 1, k + 1)):
    
    if k < math.ceil((s - i) / 2):
        continue
    else:
        ans += 2 * (min(k, (s - i)) - (s - i) // 2)
        if (s - i) % 2 == 0:
            ans += 1
print(ans)

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

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

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

print(cnt)

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

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

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

cnt = 0

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

Solution (Python):
K, S = map(int, input().split())
ans = 0
for Z in range(K+1):
  r = S - Z
  if r < 0:
    ans += 0
  elif r <= K:
    ans += r+1
  elif r <= K*2:
    ans += (K+1)*2 - (r+1)
print(ans)

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

print(ct)

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

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

Solution (Python):
from sys import stdin
lis =[]

lis= stdin.readline().rstrip().split()
k = int(lis[0])
s = int(lis[1])
count = 0
x = 0
y = 0
z = 0
for x in range(k+1):
    y = 0
    for y in range(k+1):
        z = 0
        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 i in range(k+1):
    for j in range(k+1):
        if s-(i+j) <= k and s-(i+j) >= 0:
            count += 1
print(count)

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

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

        if temp >=0 and temp <= K:
            count = 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):
def main():
  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)

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

print(ans)

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

counter = 0
for z in range(0, k+1):
  if 2 * k < s - z:
    continue
  for y in range(0, k+1):
    if k + y + z < s:
      continue
    elif   s - y - z < 0:
      break
    else:
      counter += 1
print(counter)

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

print(sum(S-K <= i+j <= S for j in range(K+1) for i in range(K+1)))

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

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

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

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

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

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

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

cnt = 0

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

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

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

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

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

Solution (Python):

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