CodeEff/ECCO huggingface dataset:
# Original solution
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        for Y in range(S + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()


# Optimized solution
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        if K < X:
            break
        for Y in range(S + 1):
            if K < Y:
                break
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()
# Original solution
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        if K < X:
            break
        for Y in range(S + 1):
            if K < Y:
                break
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()


# Optimized solution
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(K + 1):
        for Y in range(K + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()
# Original solution
import sys
K,S = list(map(int,input().split()))
#0<=S<=3K
res = 0
for X in range(0,K+1):
    if X > S:
        break
        print(res)
        sys.exit(0)
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif (0<=(S-X-Y)) and ((S-X-Y) <= K):
            res += 1
print(res)


# Optimized solution
K,S = list(map(int,input().split()))
print((sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)])))
# Original solution
K, S = list(map(int,input().split()))
ans = 0

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

# Optimized solution
K, S = list(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)
# Original solution
K, S = (int(x) for x in input().split())
sum = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if (x + y + z == S):
                sum += 1

print(sum)

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

print(sum)
# Original solution
import itertools
K,S=list(map(int,input().split()))
l=list( itertools.product(list(range(K+1)), repeat=3 ) )

cnt=0
for i,j,k in l:
	if i+j+k==S:
		cnt+=1
print(cnt)


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

# Optimized solution
(k,s),c=list(map(int,input().split())),0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z and z<=k:c+=1
print(c)
# Original solution
K,S = list(map(int, input().split()))

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

print(ans)


# Optimized solution
K,S = list(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)
# Original solution
K, S = list(map(int,input().split()))
yz = []
for y in range(K+1):
  for z in range(y,K+1):
    if y == z:
      yz.append([y+z,1])
    else:
      yz.append([y+z,2])
cnt = 0
for x in range(K+1):
  for i in range(len(yz)):
    if x + yz[i][0] == S and yz[i][1] == 1:
      cnt += 1
    elif x + yz[i][0] == S and yz[i][1] == 2:
      cnt += 2
print(cnt)

# Optimized solution
K, S = list(map(int,input().split()))
cnt=0
for y in range(K+1):
  for z in range(y,K+1):
    if y == z and 0 <= S-y-z <=K:
      cnt+=1      
    elif 0 <= S-y-z <=K:
      cnt += 2
      
print(cnt)
# Original solution
k,s = list(map(int,input().split()))
a = 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:
      a += 1

print(a)

# Optimized solution
k,s = list(map(int,input().split()))
a = 0

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

print(a)
# Original solution
K,S=list(map(int,input().split()))
print((sum(0<=S-x-y<=K for x in range(K+1)for y in range(K+1))))

# Optimized solution
K, S = list(map(int, input().split()))
ans = 0
for x in range(K + 1):
    remainder = S - x
    if remainder < 0:
        break
    elif remainder > K * 2:
        continue
    else:
        ans += remainder + 1 - 2 * max(remainder - K, 0)
print(ans)
# Original solution
K, S = [int(i) for i in input().split()]

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

print(c)

# Optimized solution
K, S = [int(i) for i in input().split()]

ans = 0
# X <= Y <= Zとしても一般性を失わない
for x in range(K + 1):
    for y in range(x, K + 1):
        z = S - x - y
        if z < y:
            break
        if z <= K:
            if x == y == z:
                ans += 1
            elif x == y or y == z or z == x:
                ans += 3
            else:
                ans += 6
print(ans)
# Original solution
n,s=list(map(int,input().split()))

ans=0
for i in range(n+1):
  for j in range(n+1):
    for k in range(n+1):
      if i+j+k==s:
        ans+=1
print(ans)

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

# Optimized solution
K, S = list(map(int, input().split()))
cnt = 0
for x in range(S + 1) :
    if x > K :
        continue
    for y in range(S - x + 1) :
        if y > K :
            continue
        z = S - x - y
        if z > K:
            continue
        cnt += 1
print(cnt)
# Original solution
k,s = list(map(int,input().split()))
cnt,x = 0,0
total = (k+1)**2
if (k*2) >= s:
	x = 0
else:
	x = s-(k*2)
while(x<=k):
	res = s-x
	for i in range(k+1):
		for j in range(k+1):
			if i+j == res:
				#print(i,j)
				cnt += 1
	x += 1
print(cnt)

# Optimized solution
k,s = list(map(int,input().split()))
cnt,x = 0,0
for y in range(k+1):
	for z in range(k+1):
		x = s-y-z
		if 0 <= x <= k:
			cnt += 1
print(cnt)
# Original solution
line = input().split(" ")
k = int(line[0])
s = int(line[1])
count = 0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if s == i + j + l:
        count += 1
print(count)

# Optimized solution
line = input().split(" ")
k = int(line[0])
s = int(line[1])
count = 0
for i in range(k+1):
  for j in range(k+1):
    if s - i - j <= k and s - i - j >= 0:
      count += 1
print(count)
# Original solution
k,s = list(map(int,input().split()))
count = 0
for i in range(k+1):
  for j in range(k+1):
    for k in range(k+1):
      result = i + j + k
      if result == s:
        count += 1
print(count)

# Optimized solution
k,s = list(map(int,input().split()))
count = 0
for i in range(k+1):
  for j in range(k+1):
    result = s - i - j
    if 0 <= result <= k:
      count += 1
print(count)
# Original solution
k,s=list(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)

# Optimized solution
k, s = list(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 <= k:
            res += 1
print(res)
# Original solution
k,s=list(map(int,input().split()))
temp=[x+y+z for z in range(k+1) for y in range(k+1) for x in range(k+1)].count(s)
print(temp)


# Optimized solution
k,s=list(map(int,input().split()))
temp=[1 for y in range(k+1) for x in range(k+1) if 0<=s-x-y<=k]
print((len(temp)))
# Original solution
k, s = list(map(int, input().split()))

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)


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

count = 0

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

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

# Optimized solution
K,S=list(map(int,input().split()))
count=0
for x in range(K+1):
    for y in range(K+1):
        sumz=S-x-y
        if sumz>=0 and sumz<=K:    
            count+=1
print(count)
# Original solution
K,S=list(map(int, input().split()))
cnt=0
for i in range(K+1):
  X=i
  for j in range(K+1):
    Y=j
    if S-(X+Y)in range(K+1):
      cnt+=1
print(cnt)

# Optimized solution
K,S=list(map(int, input().split()))
cnt=0
if K <= S:
  for i in range(K+1):
    for j in range(K+1):
      if S - (i+j) <= K and S >= i+j:
        cnt += 1
else:
  for i in range(S+1):
    for j in range(S+1):
      if S - (i+j) <= K and S >= i+j:
        cnt += 1
print(cnt)
# Original solution
K,A = list(map(int,input().split()))

ans = 0
for a in range(K+1):
  for b in range(K+1):
    for c in range(K+1):
      if a+b+c == A:
        ans += 1

print(ans)

# Optimized solution
K,A = list(map(int,input().split()))

ans = 0
for a in range(K+1):
  for b in range(K+1):
    c = A-(a+b)
    if 0 <= c <= K:
        ans += 1

print(ans)
# Original solution
K, S = [int(i) for i in input().split()]
cnt = 0 
x_flg = bool()
out = int()
for x in range(0,K+1):
  for y in range(0,K+1):
    if 0 <= S - x < K:
      cnt += S - x + 1
      break
    z = S - (x + y)
    if K >= x and K >= y and K >= z and z >= 0:
      cnt += 1
    elif z < 0:
      break
print(cnt)

# Optimized solution
K, S = [int(i) for i in input().split()]
cnt = 0 
for x in range(0,K+1):
  if 0 <= S - x <= K:
    cnt += S - x + 1
  elif 0 <= S - x <= 2*K:
    cnt += 2*K - S + x + 1
print(cnt)
# Original solution
K, S = list(map(int, input().split()))
ans = 0

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

print(ans)


# Optimized solution
K, S = list(map(int, input().split()))
ans = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - y - x
        if 0 <= z <= K:
            ans += 1
print(ans)
# Original solution
k,s=list(map(int,input().split()))
cnt=0
for i in range(k+1):
  if i>s:
    continue
  for j in range(k+1):
    if i+j>s:
      continue
    for l in range(k+1):
      if i+j+l==s:
        cnt+=1
print(cnt)

# Optimized solution
k,s=list(map(int,input().split()))
cnt=0
for i in range(k+1):
  if i>s:
    continue
  for j in range(k+1):
    if i+j>s:
      continue
    l=s-i-j
    if 0<=l<=k:
      cnt+=1
print(cnt)
# Original solution
k, s = list(map(int, input().rstrip("\n").split()))
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            x = k + 1
            y = k + 1
            continue
        count += (s <= x + y + k)

print(count)

# Optimized solution
k, s = list(map(int, input().split()))
print((sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))))
# Original solution
k, s = list(map(int, input().split()))
print((sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))))


# Optimized solution
[print(sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))) for k, s in [map(int, input().split())]]
# Original solution
k, s = list(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):
            if x + y + z == s:
                if x == y == z:
                    count +=1
                elif x == y or y==z:
                    count +=3
                else:
                    count +=6
print(count)

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

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

print(ans)

# Optimized solution
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 0<= z <=K:
            ans+=1

print(ans)
# Original solution
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 0<= z <=K:
            ans+=1

print(ans)

# Optimized solution
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K,S = list(map(int, readline().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)


if __name__ == "__main__":
    main()
# Original solution
from sys import stdin

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

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)

# Optimized solution
from sys import stdin

K, S = [int(x) for x in stdin.readline().rstrip().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)
# Original solution
K, S = list(map(int, input().split()))
count = 0
for i in range(K+1):
	for l in range(K+1):
		for m in range(K+1):
			if i + l + m == S:
				count = count + 1
print(count)

# Optimized solution
K, S = list(map(int, input().split()))
count = 0
for i in range(K+1):
	for l in range(K+1):
		if S - i - l <= K and S - i - l >=0: 
			count = count + 1
print(count)
# Original solution
K,S=list(map(int,input().split()))
cnt=0
for x in range(K+1):
  for y in range(K+1):
    z=S-x-y
    if S==x+y+z and 0<=z and z<=K:
      cnt+=1
print(cnt)

# Optimized solution
K,S=list(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)
# Original solution
k,s=list(map(int,input().split()))
o=0
for i in range(k+1):
    for u in range(k+1):
        for y in range(k+1):
            if (i+u+y)==s:
                o+=1
print(o)

# Optimized solution
k,s=list(map(int,input().split()))
o=0
for i in range(k+1):
    for u in range(k+1):
        if 0<=(s-i-u)<=k:
            o+=1
print(o)
# Original solution
k , s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if s == x + y + z:
                cnt += 1
print(cnt)

# Optimized solution
k , s = list(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)
# Original solution
K,S = list(map(int,input().split()))
ans = 0

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

# Optimized solution
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 0 <= z <= K:
            ans+=1
print(ans)
# Original solution
k,s = list(map(int, input().rstrip().split()))
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)


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


# Optimized solution
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 0 <= z and z <= k:
            ans += 1
print(ans)
# Original solution
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(eval(input()))
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return eval(input())
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    ans = 0
    l = list(itertools.combinations_with_replacement(list(range(k+1)),3))
    for i in l:
        x = i[0]
        y = i[1]
        z = i[2]
        if x+y+z == s:
            if len(set(i)) == 1:
                ans += 1
            elif len(set(i)) == 2:
                ans += 3
            else:
                ans += 6
    print(ans)

if __name__=="__main__":
    main()


# Optimized solution
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(eval(input()))
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return eval(input())
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s-x-y
            if 0<=z <=k:
                ans += 1
    print(ans)

if __name__=="__main__":
    main()
# Original solution
k,s= list(map(int,input().split()))


count = 0

arr = []
for i in range(0,k+1):
    arr.append(i)

def binary_search(arr,i):
    x = arr
    low = 0
    high = len(x)-1
    t = (low + high) // 2 
    # 探索の下限のlowが上限のhighになるまで探索
    # lowがhighに達すると数は見つからなかったということ
    while (low<=high):
        if (i==x[t]):
            break
        elif (i > x[t]):
            low = t + 1
        elif (i < x[t]):
             high = t - 1
        t = (low + high) // 2

    if (i==x[t]):
        return t
    else:
        return -1




for i in range(0,k+1):
    for j in range(0,k+1):
        l = s - i - j
        answer = binary_search(arr,l)
        # print(i,j,l)
        if(answer!=-1):
            # print('clear',i,j,l)
            count += 1


print(count)



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


count = 0

# arr = []
# for i in range(0,k+1):
#     arr.append(i)

# def binary_search(arr,i):
#     x = arr
#     low = 0
#     high = len(x)-1
#     t = (low + high) // 2 
#     # 探索の下限のlowが上限のhighになるまで探索
#     # lowがhighに達すると数は見つからなかったということ
#     while (low<=high):
#         if (i==x[t]):
#             break
#         elif (i > x[t]):
#             low = t + 1
#         elif (i < x[t]):
#              high = t - 1
#         t = (low + high) // 2

#     if (i==x[t]):
#         return t
#     else:
#         return -1




# for i in range(0,k+1):
#         l = s - i - j
#         arr = arr[]
#         answer = binary_search(arr,l)
#         # print(i,j,l)
#         if(answer!=-1):
#             # print('clear',i,j,l)
#             count += 1

for i in range(0,k+1):
    for j in range(i,k+1):
        l = s-i-j
        if l>=j and l <= k:
            if i!=j and j != l and i!=l:
                # print(i,j,l)
                count += 6
            elif i == j and j == l and i == l:
                # print(i,j,l)
                count += 1
            else:
                # print(i,j,l)
                count += 3

print(count)
# Original solution
k, s = list(map(int, input().split()))

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)

# Optimized solution
k, s = list(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)
# Original solution
k, s = list(map(int, input().split()))
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                ans += 1

print(ans)

# Optimized solution
k, s = list(map(int, input().split()))
ans = 0

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

print(ans)
# Original solution
K, S = list(map(int,input().split()))
cnt = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        for Z in range(0, K + 1):
            if X + Y + Z == S:
                cnt += 1
print(cnt)

# Optimized solution
K, S = list(map(int,input().split()))
cnt = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        if 0 <= S - X - Y <= K:
            cnt += 1
print(cnt)
# Original solution
K, S = list(map(int, input().split()))
cnt = 0
for X in range(K + 1):
    for Y in range(K + 1):
        for Z in range(K + 1):
            if X + Y + Z == S:
                cnt += 1
print(cnt)

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

# Optimized solution
k,n = list(map(int,input().split()))
ans = 0
for i in range(k+1):
  for j in range(k+1):
    if 0 <= n-i-j <= k:
      ans+=1
print(ans)
# Original solution
k, s = list(map(int, input().split()))
k = k+1

count = 0

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

print(count)

# Optimized solution
k, s = list(map(int, input().split()))
k = k+1

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

print(count)
# Original solution
k, s = list(map(int, input().split()))
count = 0
for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if i+j+m == s:
                count += 1
print(count)

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