peterverebics/CodeNet_Python_118 huggingface dataset:
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*(((5-1)*5)/2)-(S-K-5)*12))
K, S = map(int, input().split())

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

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

count = 0
for i in range(0, k + 1):
    if i > s:
        break
    for j in range(0, k + 1):
        if i + j > s:
            break
        for k in range(0, k + 1):
            if i + j + k > s:
                break
            if i + j + k == s:
                count += 1

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

count = 0
for x in range(k,-1,-1):
    a = s - x
    if a > 2*k:
        break

    for y in range(a//2, -1, -1):
        z = a - y
        if z == k:
            count += 1
        elif z > k:
            break

print(count)
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 s-x-y <= k:
            count += (s-x-y*2)*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)
k, s = map(int,input().split())
ans = 0

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

print(ans)
k,x=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1-i):
    ans+=1
print(ans)
KS = list(map(int,input().split()))

K = KS[0]
S = KS[1]
T = 0
combination_number = 0

for X in range(0,K+1):
    T = S-X
    if((T > 2*K)or(T < 0)):
        pass
    elif((T <= 2* K)and(T> K)):
        combination_number = combination_number + 1
    else:
        combination_number = combination_number + T + 1

print(combination_number)
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:
      cnt+=1
print(cnt)
k,s = map(int,input().split())

ans = 0
for h in range(k//3,k+1):
    for i in range(k//3,k+1):
        for j in range(k//3,k+1):
            if h+i+j==s:
                ans += 1
print(ans)
k, s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(x+1, k+1):
        z = s - x - y
        l = {x, y, z}
        if 0 <= z <= k:
            if len(l) == 3:
                ans += 6
            elif len(l) == 2:
                ans += 3
            else:
                ans += 1

if s % 3 == 0:
    ans += 1

print(ans)
k,s = list(map(int,input().strip().split()))
res = 0
for a in range(k+1):
  res += (s-a)+1
print(res)
K = 2
S = 2
count = 0

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

cnt = 0

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

print(cnt)
k,s=map(int,input().split())
lst=[]
for i in range(k+1):
  for j in range(k+1):
    temp = 100*i + 10*j + (s-i-j)
    if 0<= s-i-j <=k and temp not in lst:
      lst.append(temp)
print(len(lst))
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<=2500:
      cnt+=1
        
print(cnt)
K,S=map(int,input().split())
ans=0
for x in range(K+1):
  for y in range(x,K+1):
    for z in range(y,K+1):
      if x+y+z==S:
        ans+=1
print(6*ans)
K, S = map(int, input().split())

ans = 0
for i in range(K+1):
  mod = S - i
  if mod-K <= K:
    plus = min(2*K+1-mod, mod+1)
    ans += plus
print(ans)
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    s = S-i
    if s >= 0:
        cnt += min(s+1, K+1)

print(cnt)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

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

print(num)

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)
K, S = [int(n) for n in input().split(" ")]
 
cnt = 0
 
for x in range(K+1):
  for y in range(K+1):
      if S-x-y <= K:
        cnt +=1
 
print(cnt)
temp=0

k,s=map(int,input().split())
if 3*k<s: print(0)
else: 
  for a in range(s-2*k,k+1):
    temp+=2*k-(s-a)+1

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

res = 0

for X in range(min(S, K), -1, -1):
    for Y in range(min(K, S - X), -1, -1):
        if 0 <= S - X - Y <= S:
            res += 1
print(res)
li = list(map(int,input().split()))
K, S = li[0], li[1]

count = 0

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

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

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



print(ans)
import itertools

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

cnt = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

k, s = rm()
li = list(range(s//3, k+1))
cnt = 0
for i in list(itertools.product(li, repeat=3)):
  if sum(i) == s:
    cnt += 1
print(cnt)
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 i in range(a):
    if sums-i <2*a:
      for d in range(a):
        if sums-i-d<a:
          if (sums-i-d == i) | (sums-i-d == i):
            ret+=1
          else:
            ret+=2
    if sums-i == 2*a:
      ret+=1
  print(ret*3-mai)
# vim: fileencoding=utf-8


def main():
    k, s = map(int, input().split())
    c = 0
    for i in range(k + 1):
        for j in range(i, k + 1):
            for l in range(j, k + 1):
                if i + j + l == s:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()
K, S = map(int,input().split())
 
l1 = tuple([i for i in range(K+1)])
r = 0
for i in l1:
  if i > S:
    continue
  else:
    for j in l1:
      if S - i - j <= K:        
        r += 1
print(r)
K,S = map(int,input().split())

ans = 0

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

print(ans)
(k, s) = list(map(int, input().split()))
count = 0
kmin = int(s / 3)
for x in range(kmin, k + 1):
    for y in range(kmin, k + 1):
        z = s - x - y
        if z >= 0 and z <= k:
            count += 1
print(count)
K,S=map(int,input().split())
K+=1
ans=1
a=max(0,S-2*K)
for i in range(a,K):
  if i>S:
    break
  for j in range(a,K):
    if i+j>S :
      break
    if S-i+j<=K :
      ans+=1

print(ans)
import sys
import itertools
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        if s==0:
            print(1)
            sys.exit()
        elif s<=k:
            lis=list(itertools.combinations(list(range(1,s+2+1)),2))
            print(len(lis))
            sys.exit()
        else:
            if s-(x+y)<=k:
                ans+=1

print(ans)
if __name__ == '__main__':
    b, c = map(int, input().split())
    num = b*3 -c
    if num == 0:
        num =1
    else:
        if num > b:
            num = b*3
        else:
            num = num
    print(num)
K,S= map(int,input().split())

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

print(ans)
def fact(n):
  factorial = 1
  for i in range(1, n + 1):
    factorial *= i
  return factorial

def ncr(n, r):
  return fact(n) / (fact(r) * fact(n - r))


k, s = input().split()
k = int(k)
s = int(s)
count = 0
count += ncr(s + 3 - 1, 3 - 1)
count -= 3 * ncr(s - k - 1 + 3 - 1, 3 - 1)
count += 3 * ncr(s - 2*k - 2 + 3 - 1, 3 - 1)
print(int(count))
k,s=map(int,input().split())
upper  = min(k,s)+1
lower = max(0,s-2*k)
ans = 0
for i in range(lower,upper):
  for j in range(lower,upper):
    if i + j > s:
      break
    if 0 <= s-(i+j) <= k:
      ans += 1
      break
print(ans)
k, s = list(map(int, input().split()))
ans = 0
for x in range(1, k+1):
    for y in range(1, k+1):
        z = s - x - y
        if z in range(0, k+1):
            ans += 1
print(ans)
K,S=map(int, input().split())
ans = 0
x = S//3+1
for i in range(x):
  if i > K:
    break
  y = (S-i)//2+1
  for j in range(y):
    if j > K:
      break
    k = S - i - j
    if k > K:
      continue
    if i == j == k:
      ans += 1
    elif i == j or j == k:
      ans += 3
    else:
      ans += 6
print(ans)
k,s = map(int,input().split())
cnt=0
for i in range(s):
    for j in range(s):
        if i+j<=s:
            cnt+=1
print(cnt)
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    tmp=s-i
    if tmp<=k:
        ans+=tmp+1
    else:
        tmp1=2*k-tmp
        if tmp1>=0:
            ans+=tmp1+1
    # print(tmp)
print(ans)
# ABC 051 B Sum of Three Integers

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

li = [x for x in range(k+1)]
li.reverse()

res = 0
for x in range(len(li)):
    for y in range(len(li)):
        if x+y==s:
            res += 1
            break
        if x+y+max(li)<s:
            break
        for z in range(len(li)):
            if x+y+z == s:
                res += 1
                break

print(res)
x = list(map(int,input().split()))
count=0
for a in range(0,x[0]+1):
    print(a)
    for b in range(0,x[0]+1):
        for c in range(0,x[0]+1):
            if(a+b+c==x[1]):
                count+=1
print(count)
K,S = map(int,input().split())
num = 0
for i in range(K+1):
    for j in range(K+1):
        a = S - i - j
        if 0<=a<=S: num+=1
print(num)
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

s = min(K + 1, 3 * K - S + 1)

res = s * (s + 1) // 2

print(res)
k,s=map(int,input().split())
c=0
for x in range(k+1):
    for y in range(k+1):
        if x+y<=s and x+y>=2*k:
            c+=1
print(c)
K,S=map(int,input().split())

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))

  else:
      answer.append(s_z + 1)

print(sum(answer))
k,s= [int(i) for i in input().split()]

x=0
j=0

for j in range(k+1):
	if s-j<=k:
		x=x+s-j+1
	elif (s-j)<=2*k:
		x=x+(2*k-(s-j)+1)

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

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

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

print(str(answer))
K , S = map(int , input().split())
ans = 0

for x in range(K):
    for y in range(K):
        if x + y + (S-(x+y)) == S:
            ans += 1
ans += ans/2
print(ans)
# B
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:
            count += 1
print(count)
k, s = map(int, input().split())

if k * 3 < s:
    print(0)
else:
    r = k * 3 - s
    r = min(r, s)
    ans = (r + 2) * (r + 1) // 2

print(ans)
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
    else:
        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
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

import math
#mod = 10**9+7
def main():
  k,s = map(int,input().split())
  a_1 = 3 * k
  a_2 = a_1 - s
  if a_2 == 0:
    print(1)
    exit()
  ans = math.factorial(a_2)// (math.factorial(a_2-2) * math.factorial(2))
  print(ans)
  
if __name__ == '__main__':
  main()
from itertools import combinations_with_replacement

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

ans = 0
for i, j, k in combinations_with_replacement(range(k+1), 3):
    if i + j + k == s:
       ans += 1

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

print(ans)
k,s=map(int,input().split())
ans=0
if s-2*k>0:
    n=3*k-s+1
    print((n*(n+1))//2)
else:
    print((s+2)*(s+1)//2)
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):
            if 0<=i+j-S<=K:
                ans+=1

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

print(count)
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  for x in range(a+1):
    if (sums-x <=2*a)&(sums>=x):
      for y in range(a+1):
        if sums-x-y>=0:
          ret+=1
  print(ret)
k, s = map(int, input().split())

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

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


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

if __name__ == '__main__':
    main()
K, S = map(int, input().split())
K = K + 1
count = 0
k = 0
for i in range(K):
    for j in range(K):
        if i + j + k == S:
            continue
        for k in range(K):
            if i + j + k == S:
                count += 1
print(count)
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    ret=0
    k,s = map(int,input().split())
    for x in range(k+1):
        for y in range(k+1):
            if s-x-y <= k:
                ret+=1
    print(ret)
 
if __name__=='__main__':
    main()
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S, K = map(int, readline().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)
K,S = map(int,input().split())
alist = [i+j+h==S for i in range(0,K) for j in range(0,K) for h in range(0,K)]
print(len(alist))
K,S = map(int,input().split())
res = 0
I = max((S+1,K+1))
for X in range(0,I):
    if X > S:
        break
    for Y in range(0,I):
        if X + Y > S:
            break
        elif (0<=S-X-Y) and ((S-X-Y) <= K):
            res += 1
print(res)
k,s=map(int,input().split())
cnt=0
for x in range(k):
  for y in range(k):
    z=s-x-y
    if z>=0 and z<=k:
      cnt+=1
        
print(cnt)
K, S = map(int, input().split() )
cnt = 0
cnt_one = 0
for x in range(K+1):
  for y in range(x+1):
    for z in range(y+1):
      if x+y+z == S:
        if x == y & x==z:
          cnt_one +=1
        else:
          cnt+=1
print(cnt*3 + cnt_one)
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K-i+1):
        if S - i - (K - j) <= K:
            cnt += 1
            break
print(cnt)
(k, s) = list(map(int, input().split()))
count = 0
kmax = int(s / 3) + 1
for x in range(kmax + 1):
    for y in range(kmax + 1):
        for z in range(kmax + 1):
            if s == x + y + z:
                count += 1
print(count)
K, S = map(int, input().split())

p = (min(2*K, S) - max(0, S-K) +1)

ans = 0
while p>0:
    ans += p
    p -=1

print(ans)
k, s = map(int, input().split())
arr = [[x, y, s-x-y] for x in range(k+1) for y in range(k+1) if k >= s-x-y > 0]
print(len(arr))
import itertools
k,s=map(int,input().split())

arr=[]
cnt=0

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

res = 0

for X in range(min(S, K), -1, -1):
    for Y in range(min(K, S - X), -1, -1):
        if S - X - Y >= 0:
            res += 1
print(res)
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(x, y, S-(x+y))
      
print(ans)
def main():
	K,S = map(int,input().split())
	ans = 0
	ListK = [i+1 for i in range(K)]
	for x in ListK:
		for y in ListK:
			if S - (x + y) <= K:
				ans += 1

if __name__ == '__main__':
	main()
K, S = map(int, input().split())
K = K + 1
count = 0
for i in range(K):
    for j in range(K):
        z = S - i - j
        if z < K and z > 0:
            count += 1
print(count)
K,S= map(int,input().split())

ans = 0
for X in range(K+1):
    T = S-X
    if T <= K:
        ans += T + 1
    elif T <= 2*K:
        ans += 2*K-T+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 N <= K:
            ans +=1

print(ans)
K,S=map(int, input().split())
count = 0
for x in range(K+1):
  for y in range(S-x+1):
    for z in range(S-x-y+1):
      if x+y+z == S:
        count = count + 1
print(count)
from math import *

def nHr(n, r):
   if 0 < r:
      return factorial(n+r-1) / (factorial(r) * factorial(n-1))
   else:
      return 0

lst = input().split()
K = int(lst[0])
S = int(lst[1])

a = nHr(3, S)
b = (3 * nHr(3, S - K)) - (3 * nHr(3, S - (2*K)))

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

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

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

print(ans)
K, S = map(int, input().split())
ans = 0 
for X in range(S//3, K + 1):
    for Y in range(S // 3, K + 1):
        if X + Y > S:
            continue
        for Z in range(S//3,K + 1):
            if X + Y + Z == S:
                ans += 1
print(ans)
def main():
    K, S = map(int, input().split())
    ans = 0
    for X in range(K + 1):
        for _ in range(K - X + 1):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
K,S= map(int,input().split())

ans = 0
for X in range(0,K+1):
    for Y in range(X,K+1):
        for Z in range(Y,K+1):
            if X + Y + Z == S:
                if X == Y == Z:
                    ans += 1
                else:
                    ans += 3

print(ans)
K, S = map(int, input().split())
res = 0
for XY in range(2*K+1):
    Z = S - XY
    if Z in range(K):
        res += 2
    else:
        res += 1

print(res)
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 i in range(a):
    if sums-i <2*a:
      for d in range(a):
        if sums-i-d<a:
          if sums-i-d == d:
            ret+=1
          else:
            ret+=2
    if sums-i == 2*a:
      ret+=1
  print(ret*3-mai)