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

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

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

print(c)
k,s=map(int,input().split())
print(len([1 for x in range(k+1) for y in range(k+1) if 0<=s-x-y<=k]))
K,S = input().strip().split()
K,S = int(K),int(S)

count = 0

for x in range(S+1):
  for y in range(S+1-x):
    z = S - x- y
    #print( x,y,z)
    if x <= K and y <= K and z <= K:
      count += 1
print(count)
import numpy as np

K, S = map(int, input().split())
fft_len = 1 << (K * 3).bit_length()

x = np.ones(K + 1)
Fx = np.fft.rfft(x, fft_len)
Fx3 = Fx * Fx * Fx
conv = np.fft.irfft(Fx3, fft_len)

ans = conv[S]
ans = int(ans + 0.5)
print(ans)
K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        rest = S - (x + y)
        if rest >= 0 and rest <= K:
            ans += 1
print(ans)
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
                if K >= S - (x + y) >= 0 :
                    count += 1
                    
    print(count)

if __name__ == '__main__':
    K, S = map(int, input().split())
    solve(K, S)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    if x > s:
        break
    else:
        for y in range(k+1):
            if x+y > s:
                break
            elif s - x - y <= k:
                ans += 1
print(ans)
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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 and x+y+z == s):
            #print(x,y,z)
            ans += 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
    ans += (0 <= z <= k)
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 z >= 0 and z <= 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 0<=s-x-y<=k:
      ans += 1
      
print(ans)
# -*- coding: utf-8 -*-

# for文を3つ回すと間に合わない
# a + b + c = s が決まるとき a, b, s が決まれば c が決まる

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

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

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

z = list(range(0,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 + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)

print(sum(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 a in range(K+1):
  for b in range(K+1):
    if S-a-b>=0 and S-a-b<=K:
      cnt += 1
        
print(cnt)
# B - Sum of Three Integers

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

for i in range(k+1):
    for j in range(k+1):
        if i + j <= s and i + j >= min_limit:
            c += 1
print(c)
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)
import itertools
url = "https://atcoder.jp//contests/abc057/tasks/abc057_a"

def main():
    k, s = list(map(int, input().split()))
    count = 0
    for x, y in itertools.product(range(k+1), range(k+1)):
        z = s - x - y
        if 0 <= z <= k:
            count += 1
    print(count)


if __name__ == '__main__':
    main()
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)
def actual(K, S):
    my_range = lambda n: range(n + 1)

    count = 0

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

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

print(actual(K, S))
import sys
in1 = sys.stdin.readlines()

#in1 = ['10 15']

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)
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)
K,S = [int(i) for i in input().split()]
count = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if 0 <= k and k <= K:
            count += 1

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

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

count=0

for x in range(K+1):
    for y in range(x+1):
        z=S-x-y
        if z<0 or z>y:
            pass
        else:
            #print(x,y,z)
            if x==y==z:
                count+=1
            elif x==y or x==z or y==z:
                count+=3
            else:
                count+=6
        
print(count)
k,s=map(int,input().split())
ret=0
k+=1
for i in range(k):
  for j in range(k):
    d=s-i-j
    if k>d>=0:
      ret+=1
print(ret)
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()
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)
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(k+1):
    ans += (1 if 0 <= s-i-j <= k else 0)
print(ans)
X = [int(e) for e in input().split()]
ans = 0
for i in range(0,X[0]+1):
    for k in range(0,X[0]+1):
        if(X[1] - (i+k))<=X[0] and X[1] - i - k >= 0:
            ans += 1
print(ans)
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):
    if x+y <= s:
      z = s-(x+y)
      if z <= k:
        count += 1
print(count)
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)
import sys
input = sys.stdin.readline
def main():
    K, S = 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)            

if __name__ == '__main__':
    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 i in range(k+1):
    for j in range(k+1):
        if  s>=i+j and s-i-j<=k:
            ans+=1
print(ans)
import sys
k, s = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
for x in range(min(k+1, s+1)):
    for y in range(min(k+1, s - x + 1)):
        if s - x - y <= k:
            cnt += 1
print(cnt)
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)
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 X in range(K+1):
  for Y in range(K+1):
    if 0 <= S-X-Y <= K:
      count += 1
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
print(ans)
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)
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
      if k>=s-x-y>=0:
        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())
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)
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())

if S < K:
  K = S
 
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*2 - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(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) <= k:
            cnt += 1




print(cnt)
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)
k,s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(x, k+1):
        z=s-x-y
        if y <= z <= k:
            if x==y and y==z:
                count += 1
            elif x==y or y==z or z==x:
                count += 3
            else:
                count += 6
        
print(count)
print("\n")
K, S = map(int, input().split())
c = 0
for x in range(K + 1):
    for y in range(x + 1):
        if x + y > S:
            break
        z = S - x - y
        if z >= 0 and z < y + 1:
            if x != y and x!= z and y!= z:
                c += 6
            elif x == y and x == z and y == z:
                c += 1
            else:
                c += 3
print(c)
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 0<=k<=K:
            num+=1
print(num)
K, S = map(int, input().split())

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

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

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

      cnt += 1
print(cnt)
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

k,s = nm()
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)
K, S = map(int, input().split())
result = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - x - y <= 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())
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)
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):
        z=s-(x+y)
        if z>=0 and z<=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):
        if 0 <= s-i-j <= 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):
        if 0 <= S - (x+y) <= K:
            count += 1
print(count)
K,S = map(int, input().split())
print(sum(max(0, min(2*K-S+z+1, S-z+1)) for z in range(K+1)))
k,s=[int(i) for i in 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)
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(min(K,S-x)+1):
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)
k, s = map(int, input().split())
t = 0
for x in range(k + 1):
    for y in range(k + 1):
        if k >= s - x - y >= 0:
            t += 1
print(t)
def resolve():
    ks = input().split(" ")
    k = int(ks[0])
    s = int(ks[1])

    n = 0

    for zz in range(k+1):
        for yy in range (k+1):
                if (0 <= s-(yy+zz) <= k):
                    n += 1

    print(n)

if __name__ == "__main__":
    resolve()
K,S = list(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 >= 0:
            ans+=1
#             print(x,y,z)
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 <= K:
            ans += 1

print(ans)
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353

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

cnt = 0
for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if l>=0 and l<=k:
            cnt += 1
print(cnt)
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 15 13:34:38 2020

@author: NEC-PCuser
"""

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

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

print(count)
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)
import sys
readline = sys.stdin.buffer.readline

k,s = map(int,readline().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())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
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())
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 = list(map(int, input().split()))

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

print(str(answer))
a,b=map(int,input().split())
ans=0
for i in range(a+1):
    for j in range(a+1):
        if 0<=(b-i-j)<=a:
                ans+=1
print(ans)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,s = inpl()
res = 0
for i in range(n+1):
    for j in range(n+1):
        if 0 <= s - (i+j) <= n:
            res += 1
print(res)
import sys
def S(): return sys.stdin.readline().rstrip()


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

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

print(ans)
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)
K, S = map(int, input().split())
Sum = 0

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

print(Sum)
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline
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())
count=0
for x in range(k+1):
  for y in range(k+1):
    if x+y>=s-k and x+y<=s:
      count +=1
print(count)
import sys
sys.setrecursionlimit(10 ** 5)


readline =sys.stdin.readline

def process():
    k,s = map(int,readline().rstrip().split())
    cnt=0

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


print(process())
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)
import sys
sys.setrecursionlimit(10 ** 5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w') 

readline =sys.stdin.readline

# time - O(n2)
def process():
    k,s = map(int,readline().rstrip().split())
    cnt=0

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



# for _ in range(int(readline().rstrip())):
print(process())
K, S = map(int, input().split())
result = 0
for i in range(K+1):
  for j in range(K+1):
    if S-i-j<0:
      break
    else:
      if (S-i-j)>K:
        pass
      else:
        result += 1
print(result)
k,s= [int(i) for i in input().split()]

x=0
j=0

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

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

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

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())
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)
k,s=map(int,input().split())
cnt=0
for z in range(0,min(k+1,s+1)):
  s_=s-z
  if s_<=k:
    cnt+=(s_+1)
  else:
    v=s_-k
    if v<=k:
      cnt+=(k-v+1)
print(cnt)
k, s = map(int, input().split())
count = 0
for a in range(k+1):
  for b in range(k+1):
      if s-k <= a + b <= s:
        count += 1
      else:
        pass
print(count)
#!/usr/bin/env 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)
import sys
input = sys.stdin.readline

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

# X + Y = A
# Z = S - A
ans = 0
for A in range(2*K+1):
    Z = S - A
    if 0 <= Z and Z <= K:
        for X in range(K+1):
            Y = A - X
            if 0 <= Y and Y <= K:
                ans += 1
print(ans)
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    if s-i>=0:
        for j in range(min(s-i+1,k+1)):
            if s-i-j<=k and s-i-j>=0:
                ans+=1
print(ans)
k,s=map(int,input().split())

way=0

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