Problem:
 Score : 200 points    Problem Statement You are given two integers K and S . Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K . How many different assignments of values to X, Y and Z are there such that X + Y + Z = S ?      Constraints  2≤K≤2500   0≤S≤3K   K and S are integers.         Input The input is given from Standard Input in the following format:  K  S       Output Print the number of the triples of X, Y and Z that satisfy the condition.        Sample Input 1 2 2      Sample Output 1 6  There are six triples of X, Y and Z that satisfy the condition:   X = 0, Y = 0, Z = 2   X = 0, Y = 2, Z = 0   X = 2, Y = 0, Z = 0   X = 0, Y = 1, Z = 1   X = 1, Y = 0, Z = 1   X = 1, Y = 1, Z = 0        Sample Input 2 5 15      Sample Output 2 1  The maximum value of X + Y + Z is 15 , achieved by one triple of X, Y and Z .

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

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

ans = 0

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

print(ans)

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

ans = 0
for X in range(K+1):
  ans += max(0, min(K, S-X) - max(0, S-X-K) + 1)
print ans

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

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

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

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

Solution (Python):

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

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

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

print(cnt)

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

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

print(ans)

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

print(count)

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

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

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

result = 0

for x in range(K + 1):
    c = max(K - abs(S - K - x) + 1, 0)
    
    result += c

print(result)

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

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

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

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

def getAns(k, s) :
    cnt = 0
    for x in range(k + 1) :
        for y in range(k + 1) :
            z = s - x - y
            if 0 <= z <= k :
                cnt += 1
    return cnt
print(getAns(K, S))

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

n = 0

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

                
print(n)

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

Solution (Python):

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

Solution (Python):


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


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

print(answer)

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

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

print(ans)

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

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

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

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

print(c)

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

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

ans = 0
for z in range(min(k, s)+1):
    ans += max(0, min(s-z, k)+1-(max(0, s-z-k)))
print(ans)

Solution (Python):
l     = input().split()
K, S  = map(int, l)
max   = K+1
count = 0
z     =	0

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

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

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

count=0
for x in range(k+1):
  y_z = s-x
  if y_z < 0:
    count +=0
  elif 2*k < y_z:
    count += 0
  elif y_z <= 2*k:
    count += min(y_z+1,2*k-y_z+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())

count = 0

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

Solution (Python):
import itertools

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

count = 0
for x in range(max(0, s - 2 * k), min(k + 1, s + 1)):
    count += min(s - x, 2 * k - (s - x)) + 1

print(count)

Solution (Python):
import itertools

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

count = 0
for x, y in itertools.product(range(k + 1), repeat = 2):
    if x + y <= s <= x + y + 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(k + 1):
        if x + y <= s <= x + y + k:
            count += 1

print(count)

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

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

print(ans)

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys

"""テンプレ"""


input = sys.stdin.readline


def intline():
    return list(map(int, input().split()))



def strline():
    return list(map(str, input().split()))



def intlines(n):
    return [int(input() for _ in range(n))]



def lines(n):
    return [input() for _ in range(n)]
    


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)



class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        
        self.weight = [0] * (n+1)

    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    
    def same(self, x, y):
        return self.find(x) == self.find(y)

    
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]




"""ここからメインコード"""

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

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

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

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

print(ans)

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

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

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

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

counter = 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)):
			counter += 1 

print(counter)

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

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

res = [(x) for x in range(K+1)
for y in range(K+1)
if x+y <= S and x+y >= S-K]

print(len(res))

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

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

Solution (Python):
a,b=map(int,input().split())
c=0
for i in range(a+1):
    if b-i<1:
        c+=1
        break
    elif b-i<=2*a:
        if b-i<a:
            c+=b-i+1
        else:
            c+=2*a+1-b+i
print(c)

Solution (Python):
k,s=[int(a) for a 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())


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


flag = 0


for x in X:
    for y in Y:
        
        z = S - x - y
        if z<=K and z>=0:  
            flag += 1


print(flag)

Solution (Python):
k, s = [int(x) for x in input().split()]
c = 0

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

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

ANS=0

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

print(ANS)

Solution (Python):
k,s = [int(i) for i in input().split()]
r=0

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

print(r)

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

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

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

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

Solution (Python):

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


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

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

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

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

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

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

Solution (Python):
k,s=map(int,input().split())
print(sum(0<=s-y-z<=k for z 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())

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

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

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

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

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

ret = 0 
for X in range(K+1):
  for Y in range(X, K+1):
    Z = S - X - Y
    if Z < Y: break
    if Z >= 0 and Z <= K:
      if X == Y and Y == Z: ret += 1
      elif X != Y and Y != Z and Z != X: ret += 6
      else: ret += 3

print (ret)

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










for x in range(K+1):
    for y in range(max(0,S-K-x), min(K+1,S-x+1)):
        patterns += 1
print(patterns)

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

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

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

print(counter)

Solution (Python):
import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
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())
ret = 0
for i in range(k+1):
    ret += max(0,min(s-i, 2*k-s+i)+1)
print(ret)

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

Solution (Python):
import sys

K, S = [int(_) for _ in sys.stdin.readlines()[0].strip().split(' ')]
total_pattern = 0

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

print(ans)

Solution (Python):
import sys, itertools
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]

K, S = inpl()
print(sum([0 <= S - x - y <= K for x, y in itertools.product(range(K+1), repeat = 2)]))

Solution (Python):
K, S = map(int, input().split())
ans = 0
for x in range(min(S + 1, K + 1)):

    if x + K < S - K:
        continue
    else:
        ans += (min(S - x, K) - max(0, S - K - x) + 1)

print(ans)

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

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

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

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

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

Solution (Python):



from itertools import product
def  queueAnswer(maxValue,sumNumber):
	baseList = list(range(0,maxValue+1,1))
	xyPool = product(baseList,baseList)
	counter = 0
	for x,y in xyPool:
		z = sumNumber - x - y
		if ( 0 <= z ) and ( z <= maxValue):
			counter = counter + 1

	answer = counter
	return answer


if __name__ == '__main__':
	k,s = map(int,input().strip().split(' '))
	solution=queueAnswer(k,s)
	print(solution)

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

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

Solution (Python):
K,S = map(int, input().split())
n = 0
for i in range(max(S-2*K,0),min(K+1,S+1)):
    X = i
    for j in range(max(S-i-K,0),min(K+1,S-i+1)):
        Y = j
        Z = S - i - j
        n += 1
print(n)

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

print(count)

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


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

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 x <= y <= z <= K:
                ans += [None, 1, 3, 6][len( set( [x,y,z]))]
   
    print(ans)

Solution (Python):
K,S = map(int,raw_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()]

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

Solution (Python):
import itertools

N,M = map(int,input().split())
X = [i for i in range(N+1)]

count = 0
for x,y in itertools.product(X,X):
	if 0 <= M - x - y <= N:
		count += 1

print(count)

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

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

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

print(result)

Solution (Python):
line = input().split(" ")
k = int(line[0])
s = int(line[1])
count = 0

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

print(count)

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

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

print(patterns)

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

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

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

Solution (Python):



def main():
    """Function."""
    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 k >= z:
                counter += 1
    print(counter)


if __name__ == "__main__":
    main()

Solution (Python):
maxi,total = map(int,input().split(" "))
ans = 0
for i in range(maxi+1):
    for j in range(maxi+1):
        if 0 <= total-i-j <= maxi:
            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())
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, raw_input().split())
res = 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:
            res += 1
print res

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

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

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

print(result)

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

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

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

nums=[i for i in range(k+1)]

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

Solution (Python):
import itertools
K,S=[int(_) for _ in input().split()]
ans=0
for i,j in itertools.product(range(K+1),repeat=2):
    if i+j<=S and S-i-j<=K:
        ans+=1
print(ans)

Solution (Python):
import itertools
K,S=[int(_) for _ in input().split()]
ans=0
for i,j in itertools.product(range(K+1),repeat=2):
    if i+j<=S and S-i-j<=K:
        ans+=1
print(ans)

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


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 X + Y <= S and S - X - Y <= K:
            count += 1
print(count)