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):
from sys import stdin
K, S = map(int, stdin.readline().rstrip().split())
l = list(i for i in range(K+1))
count = 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):
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=map(int,input().split())
c=0

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

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

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

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

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

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

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

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

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

counter = 0

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

Solution (Python):
from itertools import product

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

cnt = 0
for x, y in product(range(K + 1), repeat=2):
    z = S - x - y
    if 0 <= z <= K:
        cnt += 1
print(cnt)

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

l = 0

if s <= k:
  l = int((s+2)*(s+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

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):
import numpy as np
K, S = map(int, input().split())
arrange = np.arange(K + 1)
T = S - np.add.outer(arrange, arrange)
print(((T >= 0) & (T <= K)).sum())

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

ans = 0

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

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

ans = 0

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

print(ans)

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

if __name__ == '__main__':
    main()

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

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

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

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

print(c)

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

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

Solution (Python):
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

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

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

num = sys.stdin.readline().split(' ')
K = int(num[0])
S = int(num[1])

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

print(counter)

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



    return ans

print(main())

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

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

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

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

print(ans)

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

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
 
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())

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

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

Solution (Python):
from operator import mul
from functools import reduce
def combinations_count(n, r):
    if n<r: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

main()

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)>=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):
    z=s-x-y
    if k>=z>=0:
      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) 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 0<=s-(i+j) 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) in range(k+1):
                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):
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c

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

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()


K,S = map(int,S().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 x + y <= s and s - x - y <= k:
            ans += 1

print(ans)

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

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

print(cnt)

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




print(cnt)

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

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

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

for x in range(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()))
    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)






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

print(count)

Solution (Python):


k,s = list(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())
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 i in range(k+1):
    x=min(s-i,k)-max(0,s-k-i)
    if x>=0:
        ans+=x+1
print(ans)

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

cnt = 0

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

print(cnt)

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

"""
0<= X<= K でXを選ぶ
このとき Y+ Z= S- X
Yの最小値は，max(0, S- X- K)
Yの最大値は，min(K, S- X)
よってY, Zの選び方はmin(K, S- X)- max(0, S- X- K)+ 1 通り．
Xについて，0<= X<= Kで足し合わせればよい．
"""
ans = 0

for i in range(K+ 1):
  Y_min = max(0, S- i- K)
  Y_max = min(K, S- i)
  if(Y_max>= Y_min):
    ans+= Y_max- Y_min+ 1
    
print(ans)

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

count = 0

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

idx = 0


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

print(idx)

Solution (Python):
import collections
 

def inputStrOnebyOne():
    s = list(input())
    return s
 

def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    ret=0
    k,s = map(int,input().split())
    for x in range(k+1):
        for y in range(k+1):
            if 0 <= s-x-y <= k:
                ret+=1
    print(ret)
 
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):
k,s = map(int,input().split())
c=0
for i in range(k+1):
    for j in range(k+1):
         c += 1*(0 <= s - i -j <= k)
print(c)

Solution (Python):
k, s = map(int, input().split())
 
result = 0
for i in range(k+1):
    x = min(s-i, k) - max(0, s-k-i)
    if x >= 0:
        result += x + 1

print(result)

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

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

print(result)

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

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

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

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

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

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
if(s == 0):
  print(1)
  exit()
elif(s == 3*k):
  print(1)
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z >= 0 and z <= k):
      ans += 1
        
print(ans)

Solution (Python):
a=input().split(" ")

number1=int(a[0])
number2=int(a[1])
n1=0
n2=0

for i in range(number1+1):
    for j in range(number1+1):
        n1=number2-int(i)-int(j)
        if n1<=number1 and 0<=n1:
            n2=n2+1

print(n2)

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

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

ans = 0

for X in range(K+1):
    for Y in range(K+1):
        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 and z <= K:
            ans += 1

print(ans)

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

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

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

Solution (Python):

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

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

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

print(count)

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

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

Solution (Python):
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

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

print(c)

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

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

print(count)

Solution (Python):
from math import *

def cin(): 
    return map(int,input().split())

def cins(): 
    return input.split()

def cino(test=False): 
    if not test:
        return int(input())
    else: 
        return input()

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

def ssplit(): 
    return list(input().split())

def printlist(l): 
    for i in l:
        print(i,end=" ")

def main():
    n,k = cin()
    ans = 0
    for i in range(n+1):
      for j in range(n+1):
        if k-i-j>=0 and k-i-j<=(n):
          ans += 1
    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):
        z = S - (x + y)
        if 0 <= z and z  <= K :
            ans += 1
print(ans)

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


ans = 0

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

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

Solution (Python):


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

result = 0

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

print(result)

Solution (Python):
k,s = list(map(int, input().split()))
cnt=0
minX=max(s-2*k, 0)
maxX=min(s, k)
for x in range(minX, maxX+1):
    rest=s-x
    if k>=rest:
        cnt+=rest+1
    else:
        cnt+=2*k-rest+1
    
print(cnt)

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

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

print(ans)

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



print(count)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





k,s=mii()

cnt=0

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

Solution (Python):
k,s = list(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






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    k, s = mi()

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

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

Solution (Python):

import sys
read = sys.stdin.buffer.read

K, S = map(int, read().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
input = sys.stdin.readline









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

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

Solution (Python):



def main():
    K, S = map(int, input().split())
    ret = 0
    for z in range(K+1):
        ret += max(min(S-z, K)-max(S-z-K, 0) + 1, 0)
    print(ret)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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