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):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    K, S = MAP()
    
    ans = 0
    for x in range(K+1):
    	for y in range(K+1):
        	ans += 0 <= S - (x + y) <= K
            
    print(ans)
    
    
if __name__ == '__main__':
    main()

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

K, S = MAP()

ans = 0

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

Solution (Python):


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

ans = 0

if k * 3 == s:
    print(1)
    exit(0)
else:
    for v in range(k + 1):
        
        for x in range(k + 1):
            if v + x > s:
                continue
            else:
                targ = s - v - x
                
                if targ < 0 or targ > k:
                    pass
                else:
                    ans += 1

print(ans)

Solution (Python):



import sys
sys.setrecursionlimit(200000000)






def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    K,S=pin()
    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)
    
"""


"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 2"""
        output = """6"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5 15"""
        output = """1"""
        self.assertIO(input, output)
if __name__=="__main__":resolve()

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

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

        if 0 <= z < k+1:
            ans += 1

print(ans)

Solution (Python):
s = list(map(int, input().split(" ")))
n = s[0]
c = s[1]
ans = 0

for v in range(n+1):
    x = v
    for i in range(n+1):
        y = i
        if  0 <= (c - x - y) <= n:
                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 s-x-y >k or s-x-y<0 :
      continue
    else:
      c = c +1
print(c)

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

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


def main():
    k, s = list(map(int, input().split()))

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(K: int, S: int):
    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)
    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())

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

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

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

k,s = map(int,readline().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 sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(K + 1):
        for Y in range(K + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        if K < X:
            break
        for Y in range(S + 1):
            if K < Y:
                break
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()

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

ans=0
for a in range(K+1):
    for b in range(K+1):
        if K>=S-a-b and 0<=S-a-b:
            ans+=1
            
print(ans)

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

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 itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)

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

print(count)

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

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

Solution (Python):
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func, iter_)


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

Solution (Python):
import sys









mod = int(1e9+7)
INF = 1<<29

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

if __name__=='__main__':
    main()

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

print(count)

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

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

z = 0
count = 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:
            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(" "))
ans = 0
if S == 3*K:
  print(1)
  exit()
for z in range(K+1):
  tmp = S-z
  if tmp <= 2*K:
    for y in range(K+1):
      ttmp = tmp-y
      if 0 <= ttmp <= K:
        ans += 1
print(ans)

Solution (Python):
K,S=map(int,input().split())
result = 0
for x in range(K+1):
  Y = min(S - x, K)
  for y in range(Y+1):
    if x + y <= S and S - x - y <= 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 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(i, k + 1):
        if j <= s - i - j <= k:
            l = s - i - j
            if i == j == l:
                ans += 1
            elif i == j or j == l:
                ans += 3
            elif i != j != l:
                ans += 6
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 x+y+z==s and 0<=z<=k:
            ans+=1
print(ans)

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

K, S = map(int, input().split())
fft_len = 1 << (K * 3).bit_length()

x = np.ones(K + 1)
Fx = np.fft.rfft(x, fft_len)
Fx3 = Fx * Fx * Fx
conv = np.fft.irfft(Fx3, fft_len)

ans = conv[S]
ans = int(ans + 0.5)
print(ans)

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

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


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

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  
    S = int(next(tokens))  
    solve(K, S)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
K, S = map(int, input().split())
table = [0] * (3 * K + 1)
for x in range(K + 1):
  for y in range(K + 1):
    table[x + y] += 1
res = 0

for z in range(3 * K + 1):
  if (S - z) in range(K + 1): res += table[z]
print(res)

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

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

print(ans)

Solution (Python):
import itertools

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 <= K and z >= 0:

            cnt += 1
print(cnt)

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

Solution (Python):


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

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

print(count_num)

Solution (Python):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


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


if __name__ == '__main__':
    main()

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

Solution (Python):

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

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

def solve():
    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 0 <= z <= K: count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

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

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

if s <= k:
    for x in range(s + 1):
        for y in range (s - x + 1):
            ans += 1
elif (s > k) and (s <= 2*k):
    for x in range(k + 1):
        for y in range(s - x + 1):
            if y <= k and (s - x - y) <= k:
                ans += 1
else:
    for x in range(k + 1):
        for y in range(k + 1):
            if (s - x - y) <= k:
                ans += 1

print(ans)

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

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

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

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

Solution (Python):
K, S = map(int, input().split(' '))
count = 0
for 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())

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

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

Solution (Python):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

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


if __name__ == '__main__':
    main()

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

print(len([0 for i in range(K+1) for j in range(K+1) if 0<=S-i-j<=K]))

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):
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 z < 0 or K < z:
                continue
            ans += 1

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

Solution (Python):

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

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

print(ans)

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

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

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

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

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

Solution (Python):
k, s = [int(e) for e in 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 = 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 z >= 0 and z <= K:
      counter += 1

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

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

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

if __name__ == "__main__":
    k,s = map(int,readline().split())
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            if s-i-j <= k and i+j <= 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):
        z = s - x - y
        if 0 <= z <= k:
            count += 1
print(count)

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


if __name__ == '__main__':
    main()

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

Solution (Python):
from sys import stdin
k,s = map(int,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):
from sys import stdin
k,s = map(int,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):
from sys import stdin
k,s = map(int,stdin.readline().rstrip().split())
point = 0
for i in range(k+1):
    for j in range(k+1):
        if i+j > s:
            continue
        elif s-(i+j) <= k:
            point += 1
print(point)

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

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

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

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

print(ans)

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


if __name__ == "__main__":
    main()

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

if __name__=='__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K,S = map(int, readline().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)


if __name__ == "__main__":
    main()

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

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

print(ans)

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

result = 0

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

print(result)

Solution (Python):


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

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

count = 0

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

res = 0

for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <= 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 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):
def solve():
    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:
                z = S-(x+y)
                if x+y+z == S:
                    c += 1
    return c

print(solve())

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 = [int(i) for i in input().split()]
print([0 <= s-i-j <= k for i in range(k+1) for j in range(k+1)].count(True))

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

Solution (Python):
import itertools

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

X = range(K + 1)
Y = range(K + 1)
Z = range(K + 1)

count = 0
for i, j in itertools.product(X, Y):
  if S - i - j in Z:
    count += 1
print(count)

Solution (Python):
ks = input().split(' ')

k = int(ks[0])
s = int(ks[1])
cnt = 0

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



print(str(cnt))

Solution (Python):
def solve():
    K, S = [int(x) for x 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
    return res

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

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

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

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

get = 0

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

Solution (Python):



k,s = list(map(int, input().rstrip().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(k+1):
  for j in range(k+1):
    if s-k<=i+j<=s:
      ans+=1
print(ans)

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

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

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

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

way=0

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