peterverebics/CodeNet_Python_118 huggingface dataset:
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        m = s-j-i
        if(m <= k and 0 <= m):
            #print(i,j,m)
            count += 1

print(count)
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()
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)
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

res = 0

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

print(res)
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)
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 and S - x - y <= K:
            cnt += 1
print(cnt)
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + K - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))
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)
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
# 標準入力の取得
K,S = list(map(int, input().split()))

# 全探索を行う
available_value_list = range(K+1)

result = 0
for x in available_value_list:
    for y in available_value_list:
        z = S - x - y # x + y + z = Sより算出
        if 0 <= z and z <= K:
            result += 1

# 結果出力
print(result)
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)
k,s = map(int,input().split())
a = 0
for x in range(k+1):
  for y in range(k+1):
      if s-(x+y) <= k and s-(x+y) >= 0:
        a += 1
        
print(a)
k,s = map(int,input().split())
ans = 0

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

count = 0

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

print(count)
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:
      #print(i, j, (S - (i + j)))
      count += 1
print(count)
K, S = map(int, input().split())
ans = 0
for i in range(K+1):
    if min(S-i, K) == K:
        ans += max(2 * K - (S - i) + 1, 0)
    else:
        ans += max(S - i + 1, 0)
print(ans)
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)
def LI():
    return list(map(int, input().split()))


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

out = 0

# 全探査だと間に合わない
# zはあるかないかの２択なので外せる
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
            out += 1
print(out)
K, S = map(int, input().split())
ans = 0
for X in range(1 + K):
    for Y in range(1 + K):
        Z = S - (X + Y)
        if Z < 0 or Z > K:
            continue
        ans += 1
print(ans)
import itertools
K, S = map(int, input().split())
ans = 0

for i in itertools.product(range(K+1), repeat=2):
    if 0 <= (S - sum(i)) <= K:
        ans += 1
print(ans)
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        if x+y<=s and x+y+k>=s:
            ans+=1
print(ans)
K, S = map(int, input().split())
ans = 0
for i in range(0,K+1):
    for j in range (0,K+1):
        if (S-K) <= (i + j) <= S:
            ans += 1
            continue
print(ans)
K,S=map(int,input().split())
res=0
for i in range(K+1):
    for j in range(K+1):
        if S-i-j>=0 and S-i-j<=K:
            res+=1

print(res)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

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

cnt=0
if K*3==S:
    cnt+=1
elif K*3<S:
    pass
else:
    for x in range(K+1):
        for y in range(K+1):
            if 0<=S-x-y<=K:
                cnt+=1

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

print(ans)
import itertools

K,S = map(int,input().split())
cnt = 0
for i in itertools.product(range(K+1),repeat = 2):
    if 0 <= S - i[0] - i[1] <= K:
        cnt += 1
print(cnt)
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)
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 and z<= K):
            counter += 1
print(counter)
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:
    print(ans)
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):
            if(x == y and y == z):
                ans += 1
            elif(x != y and y != z and z != x):
                ans += 1
            else:
                ans += 1
                
                
                
print(ans)
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)
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)
k, s = map(int, input().split())
ans = 0
for x in range(min(k, s) + 1):
    for y in range(min(k, s-x) + 1):
        z = s - x - y
        if z < 0 or z > k:
            continue
        ans += 1
print(ans)
# coding = SJIS
k, s = map(int, input().split())
if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    ans = ((k + 1) * (k + 2) / 2) - ((2 * k - s) * ((2 * k - s) + 1) / 2) + (t * (2 * k - ((2 * k - s) - 1)) / 2)
elif s <= 3 * k:
    ans = (3 * k - s + 1) * ((3 * k - s + 1) + 1) / 2
print(int(ans))
k,s=map(int,input().split())
cnt=0
for i in range(k,-1, -1):
  for j in range(k, -1, -1):
    l=s-i-j
    if 0<=l<=k:
      cnt+=1
print(cnt)
K,S=map(int,input().split())
res=0
for x in range(0,K+1):
    for y in range(0,K+1):
        z = S-x-y
        if 0<=z and z<=K:
            res+=1
print(res)
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)
K, S = tmp = 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)
def main():
	K,S = map(int,input().split())
	ans = 0
	ListK = [i for i in range(K+1)]
	for x in ListK:
		for y in ListK:
			if 0 <= S - (x + y) <= K:
				ans += 1
	print(ans)

if __name__ == '__main__':
	main()
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

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

def main():
    K, S = mi()
    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)

if __name__ == '__main__':
    main()
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))
k, s = map(int, input().split())

#.
ans = 0

#.
for x in range(k+1):
    for y in range(k+1):
        #.
        des_v = s - x - y

        #.
        if des_v >= 0 and des_v <= k:
            ans += 1

print(ans)
k,s = [int(x) for x in 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)
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)
K,S = map(int, input().split())
ans = 0
for z in range(K+1):
    ans += max(0, min(2*K-S+z+1, S-z+1))
print(ans)
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)
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)
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
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)
K,S = map(int,input().split())

ans = 0

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

print(ans)
from math import factorial
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


k, s = LI()
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)
k, s = map(int, input().split())
r = range(0, k + 1)
cnt = 0
for x in r:
    for y in r:
        if x + y > s: continue
        for z in r:
            if x + y + z == r:
                cnt += 1
                
print(cnt)
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = K - x - y
    if 0 <= z <= K:
      ans += 1
print(ans)
k, s = map(int, input().split())
counter = 0
for x in range(k + 1):
    if x >= s:
        break
    for y in range(x, k + 1):
        z = s - x - y
        if y >= s:
            break
        if y <= z <= k:
            if x == y == z:
                counter += 1
            elif x == y or y == z:
                counter += 3
            else:
                counter += 6

print(counter)
K,N=map(int,input().split())
cnt=0
def souatari(K,N):
    ans=0
    if 2*K<N:
        return 0
    elif 2*K>=N and K<N:
        return 2*K-N+1
    elif K>=N:
        return N+1

for i in range(K+1):
    cnt+=souatari(K,N-i)

print(cnt)
1,9
2,8
3,7
4,6
5,5

2,9
3,8
4,7
5,6

0,10
1,9
2,8
3,7
4,6
5,5
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

count = 0
for x in range(k+1):
  if x == s:
    count += 1
  else:
    for y in range(k+1-x):
      if x+y == s:
        count += 1
      else:
        for z in range(k+1-x-y):
          if x+y+z == s:
            count += 1
print(count)
import itertools
ans = 0
k, s = map(int, input().split())
sa = [int(i) for i in range(k+1)]
tt = [int(i) for i in range(k+1)]
c = itertools.product(sa,repeat=2)

for i in c:
  if i[0] + i[1] - s  in tt:
      ans+=1

print(ans)
a,b = list(map(int, input().split()))
ans = 0

for i in range(a):
  for j in range(a):
    for k in range(a):
      if i+j+k==b:
        ans += 1
        
print(ans)
#B - Sum of Three Integers
K,S = map(int,input().split())
#0<=S<=3K
res = 0
for X in range(0,K+1):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif 0<=(X + Y - S) and (X + Y - S) <= K:
            res += 1
print(res)
K,S = map(int,input().split())

z = 0
o = 0
t = 0

for i in reversed(range(K+1)):
  if i < (S-1)//3 + 1:
    break
  else:
    num = min(S-i,i)-(S-i+1)//2 + 1
    z += num
    if (S-i) % 2 == 0:
      z -= 1
      o += 1
    if min(S-i,i) == i:
      z -= 1
      o += 1
if S % 3 == 0:
  t += 1
  o -= 1
#print(z,o,t)
print(z*6 + o*3 + t)
K,S=map(int,input().split())

if S==0:
    print("1")
elif K>=S:
    print(int(((S+1)*(S+2))/2))
else:   #K<S(S>0)
    if (S-K)<5:
        print(int((((S+1)*(S+2))/2)-3*(((S-K-1)*(S-K))/2)))
    else:
        print(int((((S+1)*(S+2))/2)-3*10-(S-K-3)*12))
k,s=map(int,input().split())
count=0

for x in range(k+1):
  for y in range(k+1-x):
    z=s-x-y
    if z>=0 and z<=k:
      count+=1
print(count)
# -*- coding: utf-8 -*-

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

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

print(count)
splited = input().split(" ")

k = int(splited[0])
s = int(splited[1])
z = [i for i in range(k+1)]

def check_sum(p):
  l, r = 0, k
  
  while(r - l >= 1):
    i = int((r + l) / 2)
    if z[i] == p:
      return True
    elif z[i] < p:
      l = i + 1
    else:
      r = i
  return False


result = 0

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

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

l = set()
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s:
            l.add((i, j, s-k-j))
        else:
            continue

print(len(l))
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

count = 0
for x in range(K+1):
  tmp = x
  if tmp > S:
    continue
    for y in range(K+1):
      tmp = x+y
      if tmp > S:
        continue
        for z in range(K+1):
            ans = x+y+z
            if ans == S:
                count += 1
                
print(count)
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

k,s = [tmp.pop(0) for i in range(2)]

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

print(c)
k,s = map(int,input().split())
ans = 0
if s>3*k:
    print(0)
elif s==3*k:
    print(1)
elif s-k<=0:
    for i in range(s+1,0,-1):
        ans += i
else:
    for i in range(k+1):
        for j in range(k+1):
            if s-k<=i+j<=s: 
                ans += 1
print(ans)
n, s = map(int, input().split())
cnt=0
for i in range(n+1):
  for j in range(n+1):
    S = s-i-j
    if S<=n:
      cnt+=1
print(cnt)
K,S = map(int,input().split())

cnt = 0

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

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed+1)*(S-ed)//2 # Σ^n{k} = n*(n+1)/2
print(res)
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
            else:
                break

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

count=0
for i in range(k+1):
  if s-i-2*k >=0:
    for j in range(k+1):
      if s-i-j-k>=0:
        for h in range(k+1):
          if i+j+h ==s:
            count+=1
print(count)
K,S = map(int,input().split())
num = 0
for i in range(K+1):
  for j in range(K+1) :
    k = S - i - j
    if k <= K :
      num += 1
print(num)
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 <= 5 and z <= 5:
            if s == y+z+i:
                count += 1
print(count)
import bisect

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

p=[]
for i in range(k+1):
    p.append(i)
    
pp=[]
for i in p:
    for j in p:
        pp.append(i+j)
pp.sort()

ans=0
for x in pp:
    if pp[bisect.bisect_right(pp,s-x)-1]==s-x:
        ans+=1
print(ans)
import math

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

res = 0

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

print(res)
import sys

num = sys.stdin.readline().split(' ')
K = int(num[0])
S = int(num[1])

counter = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(S-i-j):
            if i+j+k == S:
                counter += 1
            else:
                continue

print(counter)
K, S = map(int, input().split())
X = []
Y = []
Z = []
count = 0

for i in range(0 ,K + 1):
	for j in range(0 ,K + 1):
		for k in range(0 ,K + 1):
			X.append(i)
			Y.append(i)
			Z.append(i)
			if S == X[i] + Y[j] + Z[k]:
				count += 1

print(str(count))
import itertools

K,S = map(int, input().split())
X = list(range(K+1))
count=0

for x,y in list(itertools.product(X, X)):
    if x+y >= S-K:
        count+=1

print(count)
K, S = [int(n) for n in input().split(" ")]
 
cnt = 0
 
for x in range(K+1):
  for y in range(K+1):
    for z in range(S-x-y):
      if x+y+z == S:
        cnt +=1
 
print(cnt)
k, s = 5, 15

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

for x in range(S+1):
    for y in range(S+1):
        if x+y > S:
            break
        for z in range(S+1):
            if x+y+z == S:
                ans+=1
print(ans)
k,s=map(int,input().split())
x=[0]*k
for i in range(0,k):
  x[i]=i
x.append(k)
a=int(s/3)-1
count=0
for i in range(0,len(x)):
  stemp=s-x[i]
  for j in range(0,min(k+1,stemp)):
    if stemp-x[j] in x:
      count=count+1
print(count)
k,s=map(int,input().split())
p=0
for i in range(k+1):
    for j in range(k+1):
        if s- i - j <= k:
            p += 1
print(p)
k,s=map(int,input().split())
ans=0
if s%3==0:
  ans+=1
for i in range(k):
  if 2*k<=s<3*k:
    ans+=3
for i in range(k-1):
  for j in range(i+1,k):
    for k in range(j+1,k+1):
      if i+j+k==s:
        ans+=6


print(ans)
k,s= map(int,input().split())
cnt=0
for x in range(s+1):
    for y in range(s+1):
        if 0 <= s-x-y <= k:
            cnt+=1
print(cnt)
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(i,j,s-i-j)
print(cnt)
K,S = map(int,input().split())
res = 0
for a in range(K):
  for b in range(K):
    for c in range(K):
      if a+b+c == S:
        res += 1
        break
      break
print(res)
def main():
	K,S = map(int,input().split())
	ans = 0
	ListK = [i for i in range(K)]
	for x in ListK:
		for y in ListK:
			for z in ListK:
				if x + y + z == S:
					ans += 1
	print(ans)

if __name__ == '__main__':
	main()
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

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

# if S%3==0:
#     x=int(S/3)
# elif S%2==0:
#     x=int(S/2)
# else:
#     x=int(S)

ans=0

for i in range(0,K+1):
    for j in range(0,K+1):
        for k in range(0,K+1):
            print(i,j,k)
            if i+j+k==S:
                ans+=1

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

res = 0

for ed in range(min(S, K), -1, -1):
    res += (S-ed)*(S-ed-1)//2 # Σ^n{k} = n*(n+1)/2
print(res)
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__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0 or c ==0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = c*3
    print(num)
K, S = map(int, input().split())

count = 0
for i in range(K+1):
    for j in range(K+1):
        if(K >= S-(i+j) >= 0):
            count += 1
            print(i, j, S-(i+j))
K,S=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(X,K+1):
        for Z in range(Y,K+1):
            com=X+Y+Z
            if(com==S):
                count+=1
            else:
                pass
print(count)
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
		elif s - i - j > k: break
print(ans)
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:
      cnt += 1

print(cnt)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

print(r)
k,s = map(int,input().split())
start = s//3
ans = 0
if s < k:
    k = s

for i in range(start,k+1):
    for j in range(start,k+1):
        for l in range(start,k+1):
            if i+j+l == s:
                ans += 1
print(ans)
k,s= map(int,input().split())
ans=0
for i in range(k):
  for j in range(k):
    z=s-i-j
    if 0<=z<=k:
      ans+=1
print(ans)
K, S = map(int, input().split())
print([x+y+z == S for x in range(K+1) for y in range(K+1) for z in range(K+1)])
import itertools
s,k = map(int,input().split())
permutations_lis = list(itertools.product(range(k),repeat=3))
cnt = 0
for i in permutations_lis:
  if i[0] + i[1] + i[2] == s:
    cnt += 1
print(cnt)
K, S = map(int, input().split())
ans = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = K -(X + Y)
        if 0 <= Z <= K:
            ans += 1
print(ans)
k, s = 2,2
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if s-x-y >= 0:
            if x+y+(s-x-y) == s:
            	ans += 1
print(ans)
k, s = map(int, input().split())
ans = 0
for x in range(k):
    for y in range(k):
        for z in range(k):
            if s == x+y+z:
                ans += 1
print(ans)
k, s = map(int, input().split())

ans = 0
for x in range(k+1)[::-1]:
    y = min(s-x, k)
    z = s-x-y
    if z > k:
        break
    ans += y - z + 1

print(ans)
# coding: utf-8
x=input().split(" ")
k=int(x[0])
s=int(x[1])
sum=0
for i in range(k+1):
    if s-i<=k*2 and s-i>=k:
        sum+=k*2-s+i+1
    elif s-i<k:
        sum+=s-i+1
print(sum)
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for x in range(a+1):
    if sums-x <2*a:
      for y in range(a+1):
        if sums-x-y<a:
          if (sums-x-y == x) | (sums-x-y == y):
            ret+=1
          else:
            ret+=2
    if sums-x == 2*a:
      ret+=1
  print(ret-mai)