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().strip().split(" "))
count=0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if((x+y+z)==S):
                count+=1
                
print(count)
            
"""

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

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

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

Solution (Python):
k, s = list(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(" "))

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=(int(i) for i in input().split())

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

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

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

print(n)

Solution (Python):

K, S = map(int, input().split())
cnt=0
for x in range(K+1):
        yz = S - x
        if yz < 0:
                break
        elif yz > 2*K:
                continue
        else:
                cnt += yz + 1 - 2 * max(0, yz - K)
print(cnt)

Solution (Python):

K, S = map(int, input().split())
cnt=0
for x in range(K+1):
        yz = S - x
        if yz < 0:
                break
        elif yz > 2*K:
                continue
        else:
                for y in range(K+1):
                        z = S - x - y
                        if 0<=z<=K:
                                cnt+=1
print(cnt)

Solution (Python):

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




"""
https://beta.atcoder.jp/contests/abc009/tasks/abc51_2
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

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

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

print(ans)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def main():
    K, S = li_input()

    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)


main()

Solution (Python):
k, s = map(int, input().split())
count=0
for x in range(min(k,s)+1):
	for y in range(min(k,s-x)+1):
		z = s-x-y
		if 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 -1 < s-x-y < k+1:
                   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 -1 < (s - x - y) < k + 1:
            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):
a=list(map(int,input().split()))
ans=0
for i in range(a[0]+1):
    for j in range(a[0]+1):
        if a[1]-i-j <= a[0] and a[1]-i-j >= 0:
            ans+=1
print(str(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(" "))

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)

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

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

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

print(ans)

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):
        X = i
        Y = j
        Z = S - i - j
        if (Z<=K and Z>=0):
            count += 1

print(count)

Solution (Python):
K,S=input().split()
k=int(K)
s=int(S)
L=0
for i in range(0,k+1):
    X=i
    if 0<int(S)-X<k*2:
        for j in range(0,k+1):
            Y=j
            Z=s-(X+Y)
            if 0<=Z<=k:
                L=L+1
            else:
                L=L
    if s-X==0 or s-X==k*2:
        L=L+1
    else:
        L=L
print(L)

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

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

Solution (Python):
k,s = (int(_) for _ in 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())
c = 0

for i in range(max(0, s - 2 * k), min(s, k) + 1):
  c += min(k, s - i) - max(0, s - i - k) + 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().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 0 <= (s-i-j) <= k:
            cnt+=1
print(cnt)

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

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

print(count)

Solution (Python):
k,s = map(int, input().split())
a = (s+2)*(s+1)/2
b = (s-k+1)*(s-k)/2
c = (s-2*k)*(s-2*k-1)/2

if s <= k:
    print(int(a))
elif s <= 2*k+1:
    print(int(a-3*b))
elif s <= 3*k:
    print(int(a-3*b+3*c))

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

Solution (Python):
from sys import stdin


def main():
    k = next_int()
    s = next_int()
    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)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Solution (Python):



"""
    2 ≦ K ≦ 2500
    0 ≦ S ≦ 3K
    K, S は整数である。
"""

test = False

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


def scan(k, s):
    """
    x, y の値を動かすと z は一意に定まる。
    """
    counter = 0

    for x in range(k+1):
    
        if x > s:
            break
        if s - x > 2*k:
            continue

        for y in range(K+1):
        
            if x + y > s:
                break
            if s - x - y > k:
                continue
            if test:
                print('x = {}\ty = {}\tz = {}'.format(x, y, s-x-y))
            counter += 1

    return counter


def main():
    """
    関数に値を適用
    """
    answer = scan(K, S)
    print(answer)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
k, s = map(int, input().split())
n = 0
for i in range(k + 1):
    if (s-i)/2 > k:
        continue
    elif i > s:
        break
    for j in range(k+1):
        z = s - i - j
        if 0<= z <= k:
            n += 1
print(n)

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

print(ct)

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

ans = 0

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

print(cnt)

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

Solution (Python):
k, s = [int(i) for i in 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(max(0, S-2*K), min(K, S)+1):
    upper = min(K, S-i)
    lower = S-i - upper
    ans += upper - lower + 1

print(ans)

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

def solve_2(num):
    if num > k:
        return k - (num-k) + 1
    else:
        return num + 1
ans = 0
first = 0
if s > 2*k:
    first = s -2*k
while first <= k:
    if s - first < 0:
        break
    ans += solve_2(s - first)
    first += 1

print(ans)

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

print(ans)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

print(ans)

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

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

Solution (Python):

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

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

print(ans)

Solution (Python):
k,s=map(int,input().split())
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())
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())
ans = 0
for p in range(min(k+1,s+1)):
    for q in range(p, s+1):
        if q-p > k or s - q > k:
            continue
        else:
            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):

from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())

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

    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()

Solution (Python):

from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
                    
            else:
                break
    
    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
k, s = list(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)

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

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

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

count = 0

for z in range(K, -1, -1):
    for y in range(K, -1, -1):
        x = S - z - y
        if z >= y and y >= x and x >= 0:
            if x == y == z:
                count += 1
            elif (x == y and y != z) or (y == z and z != x):
                count += 3
            else:
                count += 6

print(count)

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

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

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 = count + 1

print(count)

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

t = 0

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

print(t)

Solution (Python):
from itertools import  product
K, S = map(int, input().split())
ans = 0
for x,y in product(range(K+1),repeat=2):
    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())
cnt = 0

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

Solution (Python):


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

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

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    K, S = map(int, input().strip().split())
    result = 0
    for z in range(0, K+1):
        target = S - z
        k = 0
        while k <= K:
            if 0 <= target - k <= K:
                result += 1
                k += 1
            else:
                k += 1
                continue
    print(result)

if __name__ == "__main__":
    main()

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

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

Solution (Python):

k, s = map(int, raw_input().split())
patterns = []
ct = 0

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

print(ct)

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

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

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

Solution (Python):
def main():
    K, S = map(int, raw_input().split())

    count = 0

    
    for i in range(K+1):
        
        for j in range(K+1):
            if i + j > S:
                break
            if S-i-j > K:
                continue
            count += 1

    print count

main()

Solution (Python):

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

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

    print(ans)

if __name__ == "__main__":
        main()

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

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().split()))
re = 0
for x in range(min(S+1, K+1)):
    for y in range(min(S+1-x, K+1)):
        if S - x - y <= K:
            re += 1
print(re)

Solution (Python):

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

ans = 0

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

print(ans)

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):
        X = i
        Y = j
        Z = S-X-Y
        if(Z<=K and Z>=0):
            count = count + 1

print(count)

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

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

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

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

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

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

print(count)

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

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

c=0

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

print(c)

Solution (Python):
k, s = list(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()]

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

p = 0
for X in range(max(0, S - 2*K), min(K, S) +1):
  Y = S - X
  p += min(Y, K) - max(Y - K, 0) + 1
  
print(p)

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

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

Solution (Python):
k, s = list(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 i in range(k+1):
  for j in range(k+1):
    if 0<=s-(i+j)<=k:
      ans+=1
print(ans)

Solution (Python):
def main():
    a = input().split(" ")
    K = int(a[0])
    S = int(a[1])
    X = Y = Z = count = 0

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

if __name__ == '__main__':
    main()

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

Solution (Python):
K,S=[int(i) for i in input().split()]
a=0
for x in range(K+1):
    for y in range(K+1):
        z=S-x-y
        if 0<=z and K>=z:
            a+=1
print(a)

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):
        Z=S-X-Y
        if 0<=Z<=K:
           a+=1 
print(a)

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):
n = input().split()
N = []
for i in n :
  N.append(int(i))
t = 0
for i in range(0,N[0]+1) :
  for j in range(0,N[0]+1):
    z = N[1] -i-j
    if 0 <= z <=N[0] :
      t += 1
print(t)

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

count = 0

for i in range(k + 1):
  for j in range(k + 1):
    if i + j > s:
      break

    if s - (i + j) > k:
      continue

    count+=1

print(count)