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

print(count)

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

Solution (Python):



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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    
    while l >= 0:
        t_sum = s - l
        m = s - t_sum
        
        if t_sum > 2*k:
            break
        
        if m < k:
            m = k
            
        while m >= 0:
            n = s - l - m
            
            if n > k:
                break
            
            if n >= 0:
                ans += 1

            m -= 1
        l -= 1

print(ans)

Solution (Python):

"""
Created on Mon Aug  3 13:34:09 2020

@author: ito
"""




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

ans = 0

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

Solution (Python):
import math

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

print(ans)

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

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

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

print(ans)

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

Solution (Python):
k,s=input().split()
k=int(k)
s=int(s)
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):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K, S = mapint()
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=list(map(int, input().strip().split()))
f=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=(s-i-j) and (s-i-j)<=k:
            f=f+1
print(f)

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

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

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

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

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

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-K) <= (i + j) <= S:
            ans = ans + 1
            continue
            

print(ans)

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


ans = 0


for x in range(k+1):
    for y in range(k+1):
        
        des_v = s - x - y

        
        if des_v >= 0 and des_v <= k:
            ans += 1

print(ans)

Solution (Python):






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





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

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

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

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

Solution (Python):





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





r = 0

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

print(r)

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

d = {}
cnt = 0
for x in range(k+1):
    for y in range(x+1):
        z = s - x - y
        if(z >= 0 and z <= y):
            if(x == y and y == z):
                cnt += 1
            elif(x == y or y == z or z == x):
                cnt += 3
            else:
                cnt += 6

print(cnt)

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

X_m = max(0, S - 2*K)
X_M = min(K, S)

ans = 0

for i in range(X_m, X_M+1):
    Y_m = max(0, S - i - K)
    Y_M = min(K, S - i)
    ans += Y_M - Y_m + 1

print(ans)

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

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

print(res)

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



import math

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

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

print(result)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    k, s = map(int, readline().split())
    ans = 0

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

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import math

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

print(cnt)

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

Solution (Python):

from collections import defaultdict
k, s = map(int, input().split())

d = defaultdict(int)
for x in range(k + 1):
    for y in range(k + 1):
        d[x + y] += 1

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

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

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


readline =sys.stdin.readline

def process():
    k,s = map(int,readline().rstrip().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
    
    return cnt


print(process())

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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


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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil



import string

from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    
    k, s = [int(x) for x in 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)

    


t = 1

for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

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

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

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


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

print(ans)

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

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

Solution (Python):
n, s = map(int, input().split())
ans = 0
for x in range(n+1):
  for y in range(n+1):
    if 0 <= s - x - y <= n:
        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())
 
c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1):
    if s<x+y:
      break
    elif s>x+y+k:
      continue
    else:
      c+=1
print(c)

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




readline =sys.stdin.readline


def process():
    k,s = map(int,readline().rstrip().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
    
    return cnt




print(process())

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 x+y+z == s:
            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):
from collections import defaultdict

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

cnt = defaultdict(int)
for x in range(k+1):
    for y in range(k+1):
        cnt[x+y] += 1

ans = 0
for key, value in cnt.items():
    if 0 <= s - key <= k:
        ans += value

print(ans)

Solution (Python):
MM = input().split()
K = int(MM[0])
S = int(MM[1])
count = 0
for a in range(K+1):
  for b in range(K+1):
    z = S-a-b
    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):
        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):
        ij = i + j
        if ij > S:
            break
        if (S - ij <= K):
            cnt += 1
print(cnt)

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

Solution (Python):
def actual(K, S):
    count = 0

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

    for x in range(K + 1):
        for y in range(K + 1):
            z = S - (x + y)

            cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
            cond2 = (x + y + z) == S

            if cond1 and cond2:
                count += 1

    return count

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

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

Solution (Python):
k, s = [int(w) for w in 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 and s - x - y <= k:
      
      count += 1
print(count)

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

Solution (Python):
k, s = 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):
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 <= K:
      ans += 1
print(ans)

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

Solution (Python):
p = input().split()

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

x = -1
y = -1
z = 0
answer = 0

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



print(answer)

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

Solution (Python):
import sys
input = sys.stdin.readline
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())
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())
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 0<=z<=k:
      ans +=1
print(ans)

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

print(ans)

Solution (Python):
K,S = map(int,input().split())
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())
if S == 0:
  print(1)
  exit()
z = 0
o = 0
t = 0
start = min(S,K)
for i in reversed(range(start+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    if num == 1:
      if (S-i) % 2 == 0 or min(S-i,i) == i:
        z -= 1
        o += 1
    else:
      if (S-i) % 2 == 0:
        z -= 1
        o += 1
      if min(S-i,i) == i:
        z -= 1
        o += 1
        
      
if S % 3 == 0:
  t += 1
  o -= 1
print(z*6 + o*3 + t)

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

ans = 0
for i in range(K+1):
  mod = S - i
  if mod-K <= K:
    up = min(i+K+1, S+1)
    down = max(i, S-K)
    if up > down:
      plus = up - down
      ans += plus
print(ans)

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

Solution (Python):
import sys












stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    
    k,s = map(int, stdin.readline().rstrip().split())
    
    
    
    
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            z = s-i-j
            if 0<=z <= k:
                ans += 1
    print(ans)



if __name__ == '__main__':
    solve()

Solution (Python):
a = input()
k, s = a.split(' ')
K = int(k)
S = int(s)
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 z in range(K+1):
    tmp=S-z
    for x in range(K+1):
        if x+K<tmp:
            continue
        if x>tmp:
            break
        ans+=1
print(ans)

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

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

for i in itertools.product(range(K+1), repeat=2):
    if 0 <= (S - sum(i)) <= K:
        ans += 1
print(ans)

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

for i in itertools.product(range(K+1), repeat=2):
    if 0 <= (S - sum(i)) <= K:
        ans += 1
print(ans)

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

res = 0

for X in range(min(S, K), -1, -1):
    for Y in range(min(K, S - X), -1, -1):
        if 0 <= S - X - Y <= K:
            res += 1
print(res)

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

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

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

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

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

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

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

print(count)

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

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

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

cnt = 0

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

Solution (Python):

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

ans = 0
x_min = max(0, s - k - k) 
x_max = min(k, s)
for x in range(x_min, x_max + 1):
    y_min = max(0, s - x - k)
    y_max = min(k, s - x)
    ans += y_max - y_min + 1
print(ans)

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

@jit
def main():
	k, s = LI()
	cnt = 0
	for x in range(k+1):
		for y in range(k+1):
			if 0 <= s - x - y <= k:
				cnt += 1
	print(cnt)


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

print(ans)

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

Solution (Python):
k, s = [int(n) for n in 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):
from itertools import combinations
K, S = map(int, input().split())
ans = 0
if K*3 < S:
    print(0)
else:
    for i in range(K+1):
        for j in range(K+1):
            if S-i-j < 0: break
            elif S-i-j <= K: ans += 1
    print(ans)

Solution (Python):
import math
import collections
import fractions
import itertools

def solve():
    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)
    return 0

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

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

for x in range(K+1):
    for y in range(K+1):
        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):
    tmp=s-i
    if tmp<0:
        continue
    if tmp<=k:
        ans+=tmp+1
    elif 2*k<tmp:
        pass
    else:
        tmp1=2*k-tmp
        ans+=tmp1+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 <= 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 max(0, s-k) <= i+j <= s:
      cnt += 1
    elif i + j > s:
      break
print(cnt)

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    K, S = read_ints()
    
    
    total = 0
    for X in range(K+1):
        if S-X < 0:
            break
        
        Y_min = max(S-X-K, 0)
        Y_max = min(S-X, K)
        if Y_min <= Y_max:
            total += Y_max-Y_min+1
    return total


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

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

for i in range(K+1) :
    if S-i>2*K :
        continue
    elif S-i<0 :
        break
    elif 0<=S-i<=K :
        ans+=S-i+1
    else :
        ans+=2*K+i-S+1

print(ans)

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

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

print(t)