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())
 
l1 = tuple([i for i in range(K+1)])
r = 0
for i in l1:
  if i > S:
    continue
  else:
    for j in l1:
      if i + j > S:
        continue
      elif S - i - j <= K:        
        r += 1
print(r)

Solution (Python):
(k, s),  = [list(map(int, s.split())) for s in open(0)]

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

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

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

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

count = 0

for x in range(k + 1):
    if x > s:
        break
    for y in range(k + 1):
        if x + y > s:
            break
        else:
            if (k + 1) > (s - x - y):
                
                count = count + 1

print(count)

Solution (Python):

import sys
INF = float("inf")


def solve(K: int, S: int):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if S-K <= x+y <= S:
                count += 1
    print(count)

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

Solution (Python):
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K, S = map(int, readline().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 += 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 = map(int, input().split())
pattern = 0
for i in range (0,K+1):
  for j in range (0,K+1):
    if K >= S - i - j and S - i - j >= 0:
      pattern += 1
print(pattern)

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

ans = 0
for X in range(K+1):
    T = S-X
    if 0 <= T <= K:
        ans += T + 1
    elif K < T <= 2*K:
        ans += 2*K-T+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 += 1
print(cnt)

Solution (Python):
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)

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

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

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

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

Solution (Python):
import math
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 K >= z:
            ans += 1
print(ans)

Solution (Python):
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return










import fractions

from fractions import gcd


import itertools
from itertools import combinations
from itertools import permutations










from queue import Queue






from operator import mul
from functools import reduce





def crange(a, b, i):
    return range(a, b + 1, i)


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    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





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

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

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

Solution (Python):


def main():

    k, s = map(int, input().split())
    ctn = 0
    for i in range(k+1):
        for j in range(k+1):
            v = s - (i + j)
            if (0<=v) & (v<=k):
                ctn += 1  
    print(ctn)
main()

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

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

Solution (Python):
import numpy as np
K, S = map(int, input().split())

x1 = np.ones(K+1, np.int32)
x2 = np.convolve(x1,x1)
x3 = np.convolve(x1,x2)
ans = x3[S]
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):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    k,s=INTM()
    ct=0
    for x in range(k+1):
        for y in range(k+1):
            z=s-x-y
            if 0<=z and z<=k:
                ct+=1
    print(ct)
if __name__ == '__main__':
    do()

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())
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):
arr = input().split()
k = int(arr[0])
s = int(arr[1])

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

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

        if 0 <= z < 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):
        z = S - x - y
        if z <= K and z >= 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 i+j<=s and s-(i+j)<=k:
            cnt+=1
print(cnt)

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

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):
def Sumofnum(K,S):
    A = min(K,S) + 1
    a = max(S - 2*K, 0)
    c = 0
    for x in range (a,A):
        B = min(S - x,K) + 1
        b = max(S - x - K,0)
        for y in range (b,B):
            c = c + 1
    print(c)
    
s = list(map(int,input().split()))
K = s[0]
S = s[1]
Sumofnum(K,S)

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

n = 0

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

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())
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):
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):
        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(0, K+1):
        for y in range(0, K+1):
            if(0<=S-x-y<=K):
                count+=1
 
    print(count)
 
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
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

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

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

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

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

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

print(counter)

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

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

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

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

print(count)

Solution (Python):
KS = input().split()
K,S = int(KS[0]), int(KS[1])
S_count = 0

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

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

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

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

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

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

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

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

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

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

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

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 or z > K:
            continue
        if x + y + z == S:
            count += 1

print(count)

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

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

def main():

    ans = 0
    for x in range(K + 1):
        for y in range(x + 1):
            z = S - x - y
            if z < 0 or\
                K < z or\
                x < z or\
                y < z:
                continue
            if x == y == z:
                ans += 1
            elif x != y != z:
                ans += 6
            else:
                ans += 3
    print(ans)

if __name__ == '__main__':
    main()

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

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

print(ways)

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


print(sum(1 for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K))

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

print(sum(min(K, S-x) - max(0, S-x-K) + 1 for x in range(max(0, S-2*K), min(K, S)+1)))

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

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

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

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

Solution (Python):
K,S = map(int, input().split())
ret = 0
for A in range(S+1):
    if A > K: continue
    for B in range(S+1-A):
        if B > K:continue
        
        if S-A-B <= K: 
            
            ret += 1
print(ret)

Solution (Python):
li = list(map(int,input().split()))
K, S = li[0], li[1]

count = 0

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

print(count)

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

cnt = 0

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

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

ans = 0
for x in range(k+1)[::-1]:
    y = min(s-x, k)
    z = s-x-y
    if z > k:
        break
    if x >= 0 and y >= 0 and z >= 0:
        ans += y - z + 1

print(ans)

Solution (Python):
K,S = map(int, input().split())
 
ans = 0
 
for X in range(K+1):
	S1 = S - X
	if S1 < 0:
		break
	else:
		if S1 <= K:
			ans += S1 + 1
		elif S1 <= 2 * K:
			ans += 2*K - S1 + 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 (z >= 0 and z <= k):
            count += 1
print(count)

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

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

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

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

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

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

Solution (Python):



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

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

print(r)

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




ans = 0

for i in range(0,min(K,S)+1):
  
  
  

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

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

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

Solution (Python):
K, S = list(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 Z>=0 and Z<=K: ans+=1
print(ans)

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

Solution (Python):
K,S = map(int, input().split())
print(sum(max(0, min(2*K-S+z+1, S-z+1)) for z in range(K+1)))

Solution (Python):
K,S = map(int, input().split())
ans = 0
for z in range(K+1):
    ans += max(0, min(2*K-S+z+1, S-z+1))
print(ans)

Solution (Python):
K, S = map(int, input().split())
ans = 0
for i in range(K+1):
    if min(S-i, K) == K:
        ans += max(2 * K - (S - i) + 1, 0)
    else:
        ans += max(S - i + 1, 0)
print(ans)

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

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

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

print(ans)

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

Solution (Python):



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


ans = 0


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

Solution (Python):

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


ans = 0


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

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

Solution (Python):

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

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())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)

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

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

print(res)

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

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

Solution (Python):

 
import math
import itertools
import sys
import copy
 

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


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

Solution (Python):


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

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

print(str(ans))

Solution (Python):
"""
Y+Z=S−X  が成り立つことは分かるものの1通りには決まりません。
満たすべき条件は 0≤Y,Z≤K と Y+Z=S−X なので、変数 Z を消去すると以下の不等式が得られます。

0≤Y≤K
0≤Z=S−Y−X≤K
変形して、Y≤S−X かつ S−X−K≤Y

つまり Y の下限は Ymin=max(0,S−X−K) 、
上限は Ymax=min(K,S−X) となります。

"""

K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  mn = max(0, S-x-K)
  mx = min(K, S-x)
  ans += max(0, mx-mn+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())
cnt=0
l=[]
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 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())
result =0

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

print(result)

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

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

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

print(ans)

Solution (Python):
import math
import fractions

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

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

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

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



nums=list(map(int,input().split()))
k = nums[0]
s = nums[1]

sm = 0
upper = 0
lower = 0
left = max(s-k*2, 0)
right = min(s, k)

for x in range(left, right + 1):
    upper = min(s-x, k)
    lower = max(s-k-x, 0)
    sm += upper - lower + 1
    
print(sm)

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

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

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

NUMS = list(range(K+1))

sums = {}

count = 0

for x in NUMS:
  for y in NUMS:
    if x+y not in sums:
      sums[x+y] = 0
    sums[x+y] += 1
for k, v in sums.items():
  z = S - k
  if z in NUMS:
    count += v
print(count)

Solution (Python):
k, s = list(map(int, input().split()))
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, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

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):
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 and Z <= K:
            answer += 1

print(answer)

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

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

    count = 0

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

    print(count)

if __name__ == '__main__':
    main()

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

def main():
    K,S = (int(x) for x in input().split())

    count = 0

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

    print(count)

if __name__ == '__main__':
    main()

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

def main():
    K,S = (int(x) for x in input().split())

    count = 0

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

    print(count)

if __name__ == '__main__':
    main()

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

ans = 0
if K*3<S:
  print(0)
  exit()

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

print(ans)

Solution (Python):

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

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)