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

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

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

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

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

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

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

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

Solution (Python):
import sys

k, s = map(int, sys.stdin.readline().split())

def main():
    cnt = 0
    for x in range(min(s, k) + 1):
        t = s - x
        if 0 <= t <= k:
            cnt += t + 1
        elif k < t <= k * 2:
            cnt += k + 1 - (t - k)
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

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


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

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

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

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

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

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

Solution (Python):
k,s = map(int,input().split())
cnt = 0
z = list(range(k+1))

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

print(cnt)

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

Solution (Python):
k,s=map(int,input().split())
ans = 0
for i in range(k+1):
  if k <=s-i<=2*k:
    ans+= k*2-s+i+1
  elif 0<=s-i<=k:
    ans+= s-i+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 = (int(i) for i in input().split())
count = 0

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

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

Solution (Python):
K, S = [int(num) for num in 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(' '))
r = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        if s - x - y <= k and s - x - y >= 0:
            r += 1
print(r)

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
x = range(k + 1)
y = range(k + 1)


for i in x:
	for j in y:
			if 0 <= s - i - j <= k:
				ans += 1

print(ans)

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


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

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


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    k, s = list(map(int, readline().split()))
    cnt = 0
    for x in range(k + 1):
        for y in range(k + 1):
            ts = s - x - y
            if 0 <= ts <= k:
                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):
        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):
        z = S-i-j
        if 0<=z<=K:
            ans += 1
print(ans)

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

count = 0
for X in range(K+1):
    for Y in range(K+1):

        Z = S-X-Y

        if 0<=Z and Z<=K:
            count = count + 1

print(count)

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



def solve(*args: str) -> str:
    k, s = map(int, args[0].split())

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

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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

print(ans)

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

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

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

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

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

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

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    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) <= k:
                c += 1
    print(c)


main()

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

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

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

print(c)

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

range_x = range(K+1)
range_y = range(K+1)

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

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):
[print(sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))) for k, s in [map(int, input().split())]]

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)+1):
        memo = s-i-j

        if 0<=memo and memo<=k:
            cnt += 1
            

print(cnt)

Solution (Python):
def main():
    k, s = map(int, input().split())
    ans = 0
    for z in range(s//3, k+1):
        for y in range((s-z)//2, s-z+1):
            x = s-z-y
            if x <= y and y <= z:
                if x == y and y == z:
                    ans += 1
                elif x == y or y == z:
                    ans += 3
                else:
                    ans += 6
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    k, s = map(int, input().split())
    ans = 0
    for z in range(s//3, k+1):
        for y in range((s-z)//2, s-z+1):
            x = s-z-y
            if x <= y and y <= z:
                if x == y and y == z:
                    ans += 1
                elif x == y or y == z:
                    ans += 3
                else:
                    ans += 6
    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):
        if 0 <= s - (x + y) <= k:
            ans += 1
print(ans)

Solution (Python):
if __name__ == '__main__':
    K,S=list(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 = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

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

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

print(ans)

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 = list(map(int, input().split()))
k = k+1

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

print(count)

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

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

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

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

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

print(cnt)

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

count = 0

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

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

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

print(count)

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

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

print(count)

Solution (Python):
K, S = map(int, 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 and z <= K:
            count += 1

print(count)

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

if 3*k == s:
    print(1)
    exit()

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

print(count)

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

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

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

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

        if 0 <= z <= K:
            res += 1

print(res)

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

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

print(ans)

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


print(sum)

Solution (Python):
[k,s]=list(map(int,input().split()))
counter=0
imax=min(s+1,k+1)
for i in range(imax):
	jmax=min(s-i+1,k+1)
	for j in range(0,jmax):
		if i<=k and j<=k and s-i-j<=k:
			counter+=1
print(counter)

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

Solution (Python):
from sys import stdin

k,s = [int(x) for x in stdin.readline().rstrip().split()]

point = 0

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

print(point)

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

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

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

print(ans)

Solution (Python):



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

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

print(r)

Solution (Python):



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

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

print(r)

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

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

print(ans)

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

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

print(cnt)

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

Solution (Python):
if __name__ == '__main__':

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

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

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

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

print(ans)

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

Solution (Python):
def solve():
    K, S = map(int, input().split())
    
    lower = S - 2 * K
    if lower < 0:
        lower = 0
    
    cnt = 0
    for x in range(lower, K + 1):
        lower = S - K - x
        if lower < 0:
            lower = 0
        upper = S - x
        if upper > K:
            upper = K
        for y in range(lower, upper + 1):
            cnt += 1
    
    print(cnt)

solve()

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

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

print(count)

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

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

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

print(count)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K,S = MI()
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            k = S - i - j
            if 0 <= k <= K:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

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

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()))
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 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):
k,s = map(int,input().split())
count = 0
for x in range(k+1):
	if s - x > 2*k:
		continue
	else:
		for y in range(k+1):
			if s - x - y > k:
				continue
			elif s - x - y < 0:
				continue
			else:
				count += 1
print(count)

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

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

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

count = 0

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

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

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 = input().split()
K,S = int(k),int(s)
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):
import sys
input = sys.stdin.readline

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

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

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

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

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

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

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

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

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

ans = 0

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


print(ans)

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

print(cnt)

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









counter = sum([1 for x in range(K + 1) for y in range(K + 1) if 0 <= S - x - y <= K])
print(counter)

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

counter = 0

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

print(counter)

Solution (Python):
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 = 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 = [int(i) for i in input().split()]
cnt = 0

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

print(cnt)

Solution (Python):



import pdb
import sys
F = sys.stdin
K, S = map(int,F.readline().split())
count = 0
for x in range(K+1):
    yplusz = S - x
    for y in range(yplusz+1):
        z = yplusz - y
        if z <= K and y <= 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):
        Z = S - i - j
        if(j>=0 and i>=0 and Z>=0 and K>=Z and S == i + j + Z):
            ans += 1
print(ans)

Solution (Python):

def resolve(k, s):
    c = 0
    for x in range(0, k+1):
        for y in range(0, k+1):
            if 0 <= s - (x + y) <= k:
                c += 1
    return c


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

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

Solution (Python):

K, S = map(int, input().split())
ans = 0
for i in range(K+1):
    for l in range(K+1):
        Z = S - i - l
        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 z >= 0 and z <= 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 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 z<0 or z>k:
      continue
    else:
      ans+=1
print(ans)

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

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

c=0
for i in range(K+1):
    if(((i+2*K)>=S)):
        for j in range(K+1):
            if(((i+j)<=S)and((i+j+K)>=S)):
                c+=1        
print(c)

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

Solution (Python):
import sys

input = sys.stdin.readline

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

count = 0

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

print(count)

Solution (Python):

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

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

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

Solution (Python):


k, s = map(int, input().split(' '))
count = 0
for i in range(0, k+1):
    x = i
    for j in range(0, k+1):
        y = j
        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 z>=0 and 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 0 <= s - x - y <= 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):
        X = i
        Y = j
        Z = S - i - j
        if 0 <= Z <= K:
            count += 1
print(count)