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

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

print(ans)

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

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1
            elif i+j>s:
                break

    print(ans)

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

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1
            elif i+j>s:
                break

    print(ans)

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

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1


    print(ans)

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

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

Solution (Python):
def main():
    K, S = map(int, input().split())
    ans = 0
    for X in range(K+1):
        Y_min = max(0, S-X-K)
        Y_max = min(K, S-X)
        ans += max(0, Y_max - Y_min + 1)
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    K, S = map(int, input().split())
    ans = sum((1 for X in range(K+1) for Y in range(K+1) if S-X-Y>=0 and S-X-Y<=K))
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    K, S = map(int, input().split())
    ans = sum([1 for X in range(K+1) for Y in range(K+1) if S-X-Y>=0 and S-X-Y<=K])
    print(ans)
if __name__ == "__main__":
    main()

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 k >= s-i-j and s-i-j>=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 = (int(x) for x in input().split())
sum_ = 0
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y <= k:
        sum_ += 1
print(sum_)

Solution (Python):
k,s = [int(x) for x 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):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


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

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


if __name__ == '__main__':
    main()

Solution (Python):
nim, mike = map(int, input().split())
    
result = 0
for X in range(0, nim + 1):
    for Y in range(0, nim + 1):
        O = mike - (X + Y)
        if 0 <= O <= nim:
            result += 1
print(result)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

import math

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

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

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

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

counter = 0

for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= 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):
import sys
in1 = sys.stdin.readlines()



K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if 0 <= S - idx1 - idx2 <= K:
            RC += 1

print(RC)

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

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

counter = 0

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

print(counter)

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
        else:
            cnt += 0

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

print(cnt)

Solution (Python):

K, S = [int(str) for str in input().strip().split()]

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

print(ans)

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

Solution (Python):
k, s = map(int,input().split())
cnt = 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:
      cnt += 1
    else:
      continue

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

print(ans)

Solution (Python):
a,b=map(int,input().split())
c=0
for l in range(a+1):
    for m in range(l,a+1):
        r=b-l-m
        if r >a:
            continue
        elif r<m:
            continue
        elif r==l==m:
            c+=1
        elif r==m:
            c+=3
        elif m==l:
            c+=3
        else:
            c+=6
print(c)

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

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

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

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

print(count)

Solution (Python):
import numpy as np
if __name__ == "__main__":
    K, S = list(map(int, input().split()))
    ans = 0
    for i in range(K+1):
        for j in range(i, K+1):
            k = S - (i+j)
            if j <= k and k <= K:
                l = len(set([i,j,k]))
                if l == 3:
                    ans += 6
                elif l == 2:
                    ans += 3
                else:
                    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):
    z = S-i-j
    if 0 <= z and z <= K:
      answer +=1
print(answer)

Solution (Python):
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]







count = 0





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

print(count)

Solution (Python):
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]







count = 0

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

print(count)

Solution (Python):
import sys

input = sys.stdin.readline


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

input = sys.stdin.readline


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
            else:
                continue
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    K, S = map(int, input().split())

    ans = 0
    X_max = min(S, K)
    for X in range(X_max + 1):
        Y_max = min(S - X, K)
        for Y in range(Y_max + 1):
            Z = S - (X + Y)
            if 0 <= Z <= K:
                ans += 1
            else:
                continue
    print(ans)


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

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

count = 0
if S % 3 == 0:
    count += 1
for x in range(K):
    if 0 <= S-2*x and S-2*x <= K and x != S-2*x:
        count += 3
for x in range(K):
    for y in range(x+1,K):
        if y >= S-x-y:
            break
        elif 0 <= S-x-y and S-x-y <= K:
            count += 6

print(count)

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

print(cnt)

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

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z 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())
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())
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 = []
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if 0 <= z <= k:
            ans.append(0)
print(len(ans))

Solution (Python):
K, S=map(int, input().split())
s=S-2*K if S-2*K>0 else 0
e=S if S<K else K
ans=0
for Z in range(s, e+1):
  if S-Z>K:
    ans+=2*K+Z-S+1
  else:
    ans+=S-Z+1
print(ans)

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

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

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 (S - (x + y) <= K and S - (x + y) >= 0):
      count += 1
print(str(count))

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

Solution (Python):

import sys

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

counter = 0

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

print(counter)

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

for x in range(K + 1):
    if S - x >= 0:
        for y in range(K + 1):
            if K >= S - x - y >= 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(" "))
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):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

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

def inpl_str(): return list(sys.stdin.readline().split())

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

Solution (Python):
k, s = map(int, input().split())
count = 0
temp = s-2*k if (s-2*k)>0 else 0
for x in range(temp, k-1):
    for y in range(x+1, k):
        if y<(s-x-y)<=k:
            count += 6
for x in range(temp, k+1):
    for z in range(temp, k+1):
        if x*2 + z == s:
            if x == z:
                count += 1
            else:
                count += 3
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 and i+j+k>=s:
            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 and s-i-j <= k:
            ans += 1
        else:
            continue
print(ans)

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

print(ans)

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


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

print(ans)

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

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

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

print(count)

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

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

def est():
  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
  return cnt
print(est())

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

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

Solution (Python):

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

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

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

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

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

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

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

resolve()

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

for i in range(0, K+1):
  for j in range(0, K+1):
    if ((S - (i+j)) <= K) & (S - (i+j) >= 0):
      pattern = pattern+1
print(pattern)

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

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

print(cnt)

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

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

print(ans)

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

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

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

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

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
import math


def main():
    K, S = map(int, input().split())
    cnt = 0
    for x in range(S+1):
        if x > K:
            continue
        res = S - x
        for y in range(res + 1):
            if y > K:
                continue
            z = res - y
            if z > K:
                continue
            else:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

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

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

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

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

print(ans)

Solution (Python):



import sys



int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(maxNum, totalNum):
    result = 0
    for x in range(0,maxNum+1):
        for y in range(0,maxNum+1):
            z = totalNum - x - y
            if 0 <= z and z <= maxNum:
                result = result + 1
    return result


if __name__ == "__main__":
    K, S = MI()
    print("{}".format(solver(K, S)))

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

out = 0



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

Solution (Python):
K, S = map(int, input().split())
X = (S + 2) * (S + 1)
if S - K - 1 >= 0:
  X -= 3 * (S - K + 1) * (S - K)
if S - 2 * K - 2 >= 0:
  X += 3 * (S - 2 * K) * (S - 2 * K - 1)

print(X // 2)

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

cnt = 0

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

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

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())
counts = 0
for x in range(k+1):
    if (s - x) > 2 * k:
        continue
    for y in range(min(k+1, s-x+1)):
        if (s - x - y) <= k:
            counts += 1
print(counts)

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

Solution (Python):
N,M = input().split()
N = int(N)
M = int(M)

sum = 0

for i in range(N + 1):
    for j in range(N + 1):
        if  0 <= M - i - j <= N:
            sum += 1
            
print(sum)

Solution (Python):
if __name__ == '__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 and z <= K:
				ans += 1

	print(ans)

Solution (Python):




"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""





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

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

      cnt += 1
print(cnt)