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


ans = 0
for i in range(K + 1):
    for j in range(i + 1):
        k = S - i - j
        if k >= 0 and k <= j:
            
            if i == j and j == k:
                ans += 1
            elif i == j or j == k:
                ans += 3
            else:
                ans += 6

print(ans)

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

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

print(counter)

Solution (Python):
Num , Sum =  map(int,input().split())
count = 0
check = 0

for x in range(Num+1):
    for y in range ( Num+1 ):

        if 0 <= (Sum - x ) - y <= Num :
            count += 1

print(count)

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

L = [1 for z in range(K+1) for y in range(K+1) if 0 <= S-y-z <= K]
print (L.count(1))

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

Solution (Python):
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

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

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

Solution (Python):
def count_patterns(K,S):
    count_result=0
    for i1 in range(K+1):
        resi1=S-i1
        if resi1<=2*K:
            for i2 in range(resi1+1):
                resi2=resi1-i2
                if i2<=K and resi2<=K:
                    
                    count_result+=1
    return(count_result)

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

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

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

print(count)

Solution (Python):

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

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())
a = (s+2)*(s+1)/2
b = (s-k+1)*(s-k)/2
c = (s-2*k)*(s-2*k-1)/2
 
if s <= k:
    print(int(a))
elif s <= 2*k+1:
    print(int(a-3*b))
elif s <= 3*k:
    print(int(a-3*b+3*c))

Solution (Python):
max_range, sum_ = map(int, input().split())

count = 0
for x in range(0, min(max_range + 1, sum_ + 1)):
    for y in range(0, min(max_range + 1, sum_ - x + 1)):
        if sum_ - x - y <= max_range:
            count += 1

print(count)

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 = 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):
import sys
def input(): return sys.stdin.readline().strip()
k,s=map(int,input().split())
c=0
for x in range(max(0,s-2*k),k+1):
    for y in range(max(0,s-x-k),min(k,s-x)+1):
        c += 1
print(c)

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

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


print(counter)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
k,s=map(int,input().split())
c=0
for x in range(k+1):
    if x + 2 * k < s:
        continue
    for y in range(k+1):
        if x + y > s:
            continue
        if x + y + k < s:
            continue
        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 0 <= S - i - j and S - i - j <= K:
            count += 1
print(count)

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

count = 0
if k < 2 or k>2500 or s<0 or s>3*k:
    print(0)
else:
    for i in range(k+1):
        for ii in range(k+1):
            temp_z = s-i-ii
            if temp_z >= 0 and temp_z <= k:
                count = count+1
print(count)

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

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

count = 0

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

print(count)

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

count = 0

for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            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,raw_input().split())
con = 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:
                        con +=1
print con

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

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

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

rcount = 0

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

print(rcount)

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

ans = 0

for X in range(K + 1):
	if X > S:
		break
	for Y in range(K + 1):
		if X + Y <= S:
			if S - (X + Y) <= K:
				ans += 1
		else:
			break

print(ans)

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

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

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

print(count)

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

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

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:
            if k >= s - (x + y):
                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 i + j > s:
            break
        elif s - i - j <= k:
            cnt += 1
print(cnt)

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

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

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

Solution (Python):
k,s=[int(i) for i 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(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 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 S-i-j<=K and S-i-j>=0:
      ans += 1
print(ans)

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

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

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

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

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

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

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

for x in range(K + 1):
    tmp1 = S - x
    if tmp1 > 2 * K:
        continue
    tmp2 = min(K, tmp1)
    for y in range(tmp2 + 1):
        z = tmp1 - y
        if z <= K:
            count += 1

print(count)

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

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

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

if __name__ == "__main__":
    main()

Solution (Python):
def solve():
    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
    return c


if __name__ == "__main__":
    print(solve())

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

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().rstrip().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 = map(int,input().split())

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

print(cnt)

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

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

print (count)

Solution (Python):


def solve(k, s):
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                ans += 1
            elif z < 0:
                break
    return ans
 
 
def main():
    k, s = map(int, input().split())
    ans = solve(k, s)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Solution (Python):
k,s = list(map(int,input().split()))
ans = 0
for i in range(k+1):
    for j in range(0,s-i+1):
        if j > k:
            break
        else:
            p = s-i-j
            if p<0:
                pass
            elif p > k:
                pass 
            else:
                ans += 1
                

print(ans)

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

R = 0

for X in range(max(0, S-2*K), K+1):
    for Y in range(max(0, S-X-K), K+1):
        if X + Y <= S:
            R += 1

print(R)

Solution (Python):
import numpy as np
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 (z>=0)&(z<=K):
            count += 1
print(count)

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

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

ans = 0
num = min(s, k)+1
for i in range(0, num):
    for j in range(0, min(k, s-i)+1):
        if 0<=s-i-j<=k:
            ans+=1
print(ans)

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

same_all = 0
same_two = 0
same_none = 0

for i in range(K, -1, -1):
    for j in range(S - i, -1, -1):
        if ( K<j or i<j):
            continue
        k = S-i-j

        if (k <= K and k<=j):
            if(i == j and j == k):
                same_all += 1
            elif(i == j or i == k or k == j):
                same_two += 1
            else:
                same_none += 1


print(same_all + same_two*3 + same_none*6)

Solution (Python):
import sys
ks = list(map(int, input().split()))
k = ks[0]
s = ks[1]
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 = ans + 1
      
print(ans)

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

ans = 0
minnn = min(k, s)+1
for i in range(0, minnn):
    minn = min(i+k, s)+1
    for j in range(i, minn):
        if s-j<=k:
            ans += 1
print(ans)

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

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

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

num = 0
for x in range(K + 1):
	rest = S - x
	if 0 <= rest and rest <= K:
		num += rest + 1
	elif K < rest and rest <=2*K:
		num += 2*K + 1 - rest
print(num)

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

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

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

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

res = 0

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

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

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

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







print(cnt)

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

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

print(goukei)

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

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

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

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

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



print(ans)

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

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

Solution (Python):
K, S = map(int, input().split())
count = 0
if K*3 < S:
    print(count)
else:
    for i in range(K, -1, -1):
        X = i
        YZ = S - X
        for j in range(K, -1, -1):
            Y = j
            Z = YZ - Y
            if Z > K:
                continue
            elif Z < 0:
                continue
            else:
                count += 1
                
print(count)

Solution (Python):
import sys

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

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

            z = S - x - y
            if z <= K:
                cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):


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

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

def solve(K, S):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if K >= z >= 0:
                count = count + 1
    return count


if __name__ == '__main__':
    K, S = map(int, input().split())
    print(solve(K, S))

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

ans = 0

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

print("%d" % ans)

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

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

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

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

print(n)

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 = 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 = [int(elem) for elem in input().split()]

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

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

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

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

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

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

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

print(count)

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

ans = 0

if S > 3*K:
    ans = 0
else:
    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 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 <= k:
            count += 1

print(count)

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

Solution (Python):
K,S = [int(i) for i in input().split()]
num = 0
for a in range(K+1):
    for b in range(K+1):
        if(S-a-b>=0 and S-a-b<= K):
            num += 1
print(num)

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

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

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

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

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:
      break
    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())
count = 0
for kx in range(0, k+1):
    for ky in range(0, k+1):
        kz = s - kx -ky
        if 0 <= kz <= k:
            count += 1
print(count)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a = input()
    print(" ".join(a.split(",")))
    return


def B():
    k, s = LI()
    ans = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - (i + j) <= k:
                ans += 1
    print(ans)
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

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

print(count)

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(K: int, S: int):
    ret = 0
    for i in range(K + 1):
        for j in range(K + 1):
            if 0 <= S - (i + j) <= K:
                ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  
    S = int(next(tokens))  
    solve(K, S)

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

print(ans)

Solution (Python):
import sys

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

ans = 0
if S == (3 * K):
    ans = 1
    print(ans)
    sys.exit()

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

print(ans)

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

Solution (Python):


import sys
import copy

sys.setrecursionlimit(1000000)





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


import sys
import copy

sys.setrecursionlimit(1000000)





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

Solution (Python):
k,s=map(int,input().split())
c=0
for l in range(s+1):
    for m in range(min(l+1,k+1)):
        if s-l<=k and l-m<=k:c+=1
        else:pass
print(c)