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(i) for i in 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())
cnt = 0
for x in range(0,k+1):
    for y in range(0,k+1):
        if 0 >= x+y-s >= -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 s - k <= x + y <= s:
            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 = [int(x) for x in input().strip().split()]

k = data[0]
s = data[1]

answer = 0;

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

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

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

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

minZ=max(S-2*K,0)
maxZ=min(S,K)

if minZ>=S-K:
  nZ=maxZ-minZ+1
  max_nY=S-minZ+1
  min_nY=S-maxZ+1
  ans=((max_nY+min_nY)*nZ)//2
  print(ans)
elif maxZ>=S-K:
  nZ_u=maxZ-(S-K)
  max_nY_u=K
  min_nY_u=S-maxZ+1
  
  ans_u=((max_nY_u+min_nY_u)*nZ_u)//2
  
  nZ_l=(S-K)-minZ+1
  max_nY_l=K+1
  min_nY_l=2*K+minZ-S+1
  
  ans_l=((max_nY_l+min_nY_l)*nZ_l)//2
  
  print(ans_u+ans_l)
  
  
else:
  nZ=maxZ-minZ+1
  min_nY=2*K+minZ-S+1
  max_nY=2*K+maxZ-S+1
  ans=((max_nY+min_nY)*nZ)//2
  print(ans)

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

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()
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):
import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

k, s = na()
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 = 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)

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

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

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

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

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

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

print(count)

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

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

"""
Created on Thu Sep  5 14:58:17 2019

@author: Owner
"""

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

cnt = 0

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

Solution (Python):
K, S = map(int, input().split())
import itertools
count = 0
for pattern in itertools.product(range(K+1), repeat=2):
    
    if S-K <= sum(pattern) <= S:
        
        count += 1

print(count)

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

Solution (Python):
ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)

Solution (Python):
K, S = (int(x) for x in input().split())
if S <= K:
    print((S+1)*(S+2)//2)
elif 2*K <= S:
    print((3*K-S+2)*(3*K-S+1)//2)
else:
    print((3*K-S+2)*(S-K+1)//2+(2*K-S)*(S+1)//2)

Solution (Python):
def resolve():
    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 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()

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

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

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

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

count = int(0)

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

Solution (Python):
import sys

input = sys.stdin.readline


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


if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
import sys

input = sys.stdin.readline


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


if __name__ == '__main__':
    AtCoder().main()

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 = [int(i) for i in input().split()]
cnt = 0 
for x in range(0,K+1):
  if 0 <= S - x <= K:
    cnt += S - x + 1
  elif 0 <= S - x <= 2*K:
    cnt += 2*K - S + x + 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 (i+j+k) >= s:
                           ans += 1
print(ans)

Solution (Python):
import sys
import random
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

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

print(ans)

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

cnt = 0

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

print(cnt)

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

Solution (Python):
def main():
    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
    return count
if __name__ == '__main__':
    print(main())

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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):
import itertools
k,s = map(int,input().split())
print(sum([0<=s-x-y<=k for x,y in itertools.product(range(k+1),range(k+1))]))

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

Solution (Python):
k, s = map(int, input().split())
print(len(['yes' 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())
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(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 x+y<=s and 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):
            if 0<=s-x-y<=k:
                z=s-x-y
                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):
    a = s - x - y
    if a >= 0 and a <= k:
      count += 1

print(count)

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

Solution (Python):
import sys
from pprint import pprint

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

Solution (Python):


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

count = 0

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

print(count)

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

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

if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    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 0 <= k <= 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 s-x-y < k+1 and 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())
a=0
b=0
c=0
l=0
while l*2<=s and l<=k:
    if s-l*2<=k:
        b+=1
    l+=1
if s%3==0:
    a+=1
    b-=1
for x in range(k+1):
    for y in range(x+1,k+1):
        if k>=s-x-y>y:
            c+=1
print(a+3*b+6*c)

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

count = 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
        count += 1

print(count)

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

print(c)

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

ans2()

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

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

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

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

print(counter)

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

print(cnt)

Solution (Python):


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


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

print(count)

Solution (Python):


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 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):
       count+=(0<=S-(x+y)<=K)

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

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

cnt=0

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

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

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

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

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

print(ans)

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

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

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

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

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

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


if __name__ == '__main__':
    main()

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

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= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        if S-i-j<=j:
            k=S-i-j
            if i==j==k:
                ans+=1
            elif i==j or j==k:
                ans+=3
            else:
                ans+=6
print(ans)

Solution (Python):
K,S= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        if S-i-j<=j:
            k=S-i-j
            if i==j==k:
                ans+=1
            elif i==j or j==k:
                ans+=3
            else:
                ans+=6
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 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):
ks = input().split()

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

ans = 0

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

print(ans)

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

cnt = 0

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

print(cnt)

Solution (Python):
from sys import stdin
K, S = [int(i) for i in stdin.readline().rstrip().split()]
output = 0
for x in range(K+1):
    for y in range(K+1):
        if (S - x - y >= 0) & (S - x - y <= K):
            output += 1

print(output)

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

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

count=0

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

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

print(ret)

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

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

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

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

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

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

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

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

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

Solution (Python):
k,s = map(int,input().split())
count = 0
m = max(0,s-2*k)
for x in range (m,min(k,s)+1):
    count += max(0,(min(k,s-x)-max(0,s-k-x)+1))
print(count)

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

Solution (Python):
ks= list(map(int, input().split())) 
 
count = 0
 
x = 0
y = 0
z = 0
 
for targetX in range(ks[0]+1):
    
    
    if targetX <= ks[0] and ks[1]-(targetX+ks[0]+ks[0]) <= 0:
    
        for targetY in range(ks[0]+1):
            
            z = ks[1] - (targetX + targetY)
            
            if 0 <= z and z <= ks[0]:
                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 = 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())

counter = 0

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

print(counter)
print("\n")

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

counter = 0


if S%3 == 0:
    counter += 1

for i in range(K):
    yz = S - i
    
    if yz%2 == 0 and yz/2 <= K and yz/2 > i:
        counter += 3
    
    if yz - i <= K and yz - i > i:
        counter += 3
    
    for j in range(i+1, K):
        k = S - i - j
        if k > j and k <= K:
            counter += 6

print(counter)
print("\n")

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

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

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-z-y<=k]))

Solution (Python):



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

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

print(result)

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

print(ans)