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

def f():
  if K * 3 >= S:
    for x in range(min(K, S), -1, -1):
      if K * 2 >= S - x:
        for y in range(min(K, S - x), -1, -1):
          if K >= S - x - y:
            yield 1

print(sum(list(f())))

Solution (Python):
from sys import stdin




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

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

Solution (Python):
'''
制約
2≦K≦2500
0≦S≦3K
K,S は整数である。

'''



import sys
input = sys.stdin.readline




def main():
    '''メイン処理'''
    k, s = map(int, input().split())

    counter = 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 z >= 0 and z <= k:
                counter += 1

    print(counter)


if __name__ == "__main__":
    
    main()

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

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

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

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

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    k, s = MI()

    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)


if __name__ == '__main__':
    solve()

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

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

answer = 0

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

print(answer)

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

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

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

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

print(count)

Solution (Python):
def actual(K, S):
    my_range = lambda n: range(n + 1)

    count = 0

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

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

print(actual(K, S))

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

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

print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

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

ans = 0
for right in range(max(s-k, 0), min(s+1, 2*k+1)):
  lower = max(0, right-k)
  upper = min(k, right)
  if right % 2 != 0:
    ans += upper - lower + 1
  else:
    ans += upper - lower + 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 :
            break
        if S - i - j <= K :
            count += 1

print(count)

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

res = 0

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

print(res)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

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

Solution (Python):
K,S = map(int,input().split())
array = [i for i in range(K+1)]
cnt = 0

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

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


K,S = map(int, input().split())
n = 0
up = math.floor(K)
for i in range(0,K+1):
    for j in range(0, K+1):
        if(0<= S-i-j <=K):
            n +=1
        else:
                n =n

print(n)

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







ans = 0
if (k * 3 < s):

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

print(ans)

'''
ans = 0
for i in dd:
    
    if (sum(i) == s):
        ans += 1

print(ans)
'''

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

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

from itertools import product

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

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

ans = 0

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

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

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

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

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

Solution (Python):

import sys
 
 
def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            tmp = S - (a + b)
            if 0 <= tmp and tmp <= K:
                cnt += 1 
    print(cnt)
    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):

import sys
 
 
def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            tmp = S - (a + b)
            if 0 <= tmp and tmp <= K:
                cnt += 1 
    print(cnt)
    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())
print(sum(0 <= S - (x + y) <= K for y in range(K + 1) for x in range(K + 1)))

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

ans = 0
num = min(k, s)

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

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

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

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


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

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K, S = MAP()

ans = 0

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

print(ans)

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

Solution (Python):
K,M=list(map(int,input().split()))
ans = 0
for i in range(K+1):
    for j in range(min(K+1,M-i+1)):
        if M-i-j > K:
            continue
        else:
            ans +=1
print(ans)

Solution (Python):
from sys import stdin
import math
import fractions
import heapq

k, s = [int(x) for x in stdin.readline().rstrip().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())

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

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

print(count)

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

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

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

Solution (Python):
def main():
    K,S = [int(x) for x in input().split()]
    cnt = 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 z < 0 or z > K:
                continue
            
            if S == x+y+z:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


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

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

Solution (Python):
import itertools

K,S = map(int,input().split())
cnt = 0
for i in itertools.product(range(K+1),repeat = 2):
    if 0 <= S - i[0] - i[1] <= 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())
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())

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

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

    memo = [[-1] * (S + 1) for _ in range(4)]

    def dfs(cur, s=0):
        if ~memo[cur][s]:
            return memo[cur][s]

        if cur == 3:
            ret = int(s == S)
            memo[cur][s] = ret
            return ret

        ret = 0
        for r in range(min(K, S - s) + 1):
            ret += dfs(cur + 1, s + r)
        memo[cur][s] = ret
        return ret

    ans = dfs(0)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
K,S=map(int,input().split())
print(sum(1for 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())
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())

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush



def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    

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




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

def solve(K,S):
    ans = 0
    for i in range(K+1):
        if i>S:
            continue
        for j in range(K+1):
            if i+j>S or i+j<S-K:
                continue
            
            ans += 1
    return ans
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):
        if k >= s - (x+y) >= 0:
            ans += 1
print(ans)

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

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

count=0

for x in range(K+1):
    for y in range(x+1):
        z=S-x-y
        if z<0 or z>y:
            pass
        else:
            
            if x==y==z:
                count+=1
            elif x==y or x==z or y==z:
                count+=3
            else:
                count+=6
        
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())
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 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):
    t = k - i
    if t < 0:
        break
    for j in range(k+1):
        if i+j <= s <= i+j+k:
            ans += 1

print(ans)

Solution (Python):
K,S = (int(x) for x in 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 x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z < 0:
            break
        if k < z:
            continue
        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: break
    if 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):
        k = S-i-j
        if 0<=k<=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(x, k+1):
        z = s - x - y
        if y<=z and z<=k:
            tmp = set([x,y,z])
            if len(tmp)==3:
                ans += 6
            elif len(tmp)==2:
                ans += 3
            else:
                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<=k:
      ans+=1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  


K, S = read_ints()
X = list(range(K + 1))  

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    print(res)


if __name__ == '__main__':
    resolve()

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):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,s = inpl()
res = 0
for i in range(n+1):
    for j in range(n+1):
        if 0 <= s - (i+j) <= n:
            res += 1
print(res)

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

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

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


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

print(count)

Solution (Python):


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

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

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

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


 
  
   
    print(cnt)

resolve()

Solution (Python):

def solve(K, S):
    import bisect
    count = 0
    z_array = [i for i in range(K+1)]
    for x in range(K+1):
        for y in range(K+1):
                z = S - x - y
                if(z >= 0 and z <= K):count+=1
    return count

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


main()

Solution (Python):

def solve(K, S):
    import bisect
    count = 0
    z_array = [i for i in range(K+1)]
    for x in range(K+1):
        for y in range(K+1):
                z = S - x - y
                if(z >= 0 and z <= K):count+=1
    return count

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


main()

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K, S = list(map(int,_in[0].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 = list(map(int, input().split()))

ans = 0

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

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

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

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

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

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

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


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

print(ans)