CodeEff/ECCO huggingface dataset:
# Original solution
K, S = [int(a) for a in input().split()]

cnt = 0
for x in range(0,K+1):
  if x > S:
    continue
  for y in range(0,K+1):
    if x+y > S:
      continue
    for z in range(0,K+1):
      check = x+y+z
      if check == S:
        cnt += 1
      elif check > S:
        continue
        
print(cnt)

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

cnt = 0
for x in range(0,K+1):
  if x > S:
    continue
  for y in range(0,K+1):
    if x+y > S:
      continue
    elif x+y+K < S:
      continue
    else:
      cnt +=1
        
print(cnt)
# Original solution
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):
        for j in range(0,X[0]+1):
            if(i + k + j)==X[1]:
                ans += 1
                break
print(ans)


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

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

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):
    if 0<=S-i-j<=K:
      ans += 1
#    print(i, j, S-i-j, ans)
      

print(ans)
# Original solution
K, S = list(map(int, input().split()))
x,y,z = 0,0,0
ans = 0

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

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

for i in range(K+1):
  x = i
  for j in range(K+1):
    y = j
    z = S - x - y
    if 0 <= z <= K:
      ans += 1
print(ans)
# Original solution
k,s = list(map(int,input().split()))
l = [a+b+c for a in range(k+1) for b in range(k+1) for c in range(k+1)]
print((l.count(s)))

# Optimized solution
k,s = list(map(int,input().split()))
l = [a+b for a in range(k+1) for b in range(k+1)]
sum = 0
for i in range(k+1):
  sum += l.count(s-i)
print(sum)
# Original solution
k,s = list(map(int, input().split()))
ans = 0
x = list(range(k + 1))
y = list(range(k + 1))
z = list(range(k + 1))


for i in x:
	for j in y:
		for k in z:
			if s - i - j <= (k+1) and i + j + k == s:
				ans += 1

print(ans)



# Optimized solution
k,s = list(map(int, input().split()))
ans = 0
x = list(range(k + 1))
y = list(range(k + 1))
z = list(range(k + 1))


for i in x:
	for j in y:
			if 0 <= s - i - j <= k:
				ans += 1

print(ans)
# Original solution
k,s = list(map(int, input().split()))
ans = 0
x = list(range(k + 1))
y = list(range(k + 1))
z = list(range(k + 1))


for i in x:
	for j in y:
			if 0 <= s - i - j <= k:
				ans += 1

print(ans)


# Optimized solution
k,s = list(map(int, input().split()))
ans = 0
x = list(range(k + 1))
y = list(range(k + 1))


for i in x:
	for j in y:
			if 0 <= s - i - j <= k:
				ans += 1

print(ans)
# Original solution
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/16
# Filename: main 
# Author: acto_mini

def main():
    K, S = list(map(int, input().split()))

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


if __name__ == '__main__':
    main()


# Optimized solution
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/16
# Filename: main 
# Author: acto_mini

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


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

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

print(cnt)
# Original solution
a = input().split()
k = int(a[0])
s = int(a[1])

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

print(count)

# Optimized solution
a = input().split()
k = int(a[0])
s = int(a[1])

count = 0

for x in range(k + 1):
    if x > s:
        break
    for y in range(k + 1):
        if x + y > s:
            break
        else:
            if (k + 1) > (s - x - y):
                # print(x, y, (s - x - y))
                count = count + 1

print(count)
# Original solution
k,s = list(map(int,input().split()))
a = 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 and y != z and z != x:
          a += 6
        elif (x == y and y != z) or (x == z and z != y) or (z == y and y!= x):
          a += 3
        else:
          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):
      if s-(x+y) <= k and s-(x+y) >= 0:
        a += 1
        
print(a)
# Original solution
K,S= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        for k in range(j+1):
            if i+j+k==S:
                if i==j==k:
                    ans+=1
                elif i==j or j==k:
                    ans+=3
                else:
                    ans+=6
                break
print(ans)

# Optimized solution
K,S= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        if S-i-j<=j:
            k=S-i-j
            if i==j==k:
                ans+=1
            elif i==j or j==k:
                ans+=3
            else:
                ans+=6
print(ans)
# Original solution
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return list(map(func, iter_))


def parg(**kwargs):
    text = ''
    for item in list(kwargs.items()):
        if text:
            text += ',\t'
        text += '{}: {}'.format(*item)
    print(text)


K, S = spline()
count = 0
k = K + 1
for x in range(k):
    if x + K * 2 < S:
        continue
    for y in range(k):
        if x + y + K < S:
            continue
        for z in range(k):
            if x + y + z == S:
                count += 1
                break
print(count)


# Optimized solution
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return list(map(func, iter_))


K, S = spline()
count = 0
k = K + 1
for x in range(k):
    for y in range(k):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
print(count)
# Original solution
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return list(map(func, iter_))


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


# Optimized solution
K, S = list(map(int, input().split()))
k = K + 1
ans = 0
for x in range(k):
    for y in range(k):
        z = S - (x + y)
        if 0 <= z <= K:
            ans += 1
print(ans)
# Original solution
# coding: utf-8
K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
    if S > 2 * K + i:
        continue
    for j in range(K + 1):
        if S > K + i + j:
            continue
        for k in range(K + 1):
            if i + j + k == S:
                ans += 1
print(ans)


# Optimized solution
# coding: utf-8
K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
    if S - i > 2 * K:
        continue
    elif S - i < 0:
        break
    if S - i > K:
        ans += 2 * K + 1 - S + i
    else:
        ans += S - i + 1
print(ans)
# 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):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1

print(cnt)
# Original solution
K, S = list(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):
      if S == x + y + z:
        count = count + 1
          
print(count)

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

count = 0
for x in reversed(list(range(0,K+1))):
  for y in reversed(list(range(0,K+1))):
    z = S - x - y
    if z >= 0 and z <= K:
      count = 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):
        Z = s - X - Y
        if k>=Z>=0:
            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):
    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
if __name__ == '__main__':
    k, s = list(map(int, input().split()))
    ans = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if i + j > s:
                break
            for l in range(k+1):
                if i+j+l == s:
                    ans += 1
                elif i+j+l > s:
                    break
            else:
                continue
        else:
            continue
    print(ans)


# Optimized solution
if __name__ == '__main__':
    k, s = list(map(int, input().split()))
    ans = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            z = s - i - j
            if i + j > s:
                break
            elif 0 <= z and z <= k:
                ans += 1
    print(ans)
# Original solution
if __name__ == '__main__':
    k, s = list(map(int, input().split()))
    ans = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            z = s - i - j
            if i + j > s:
                break
            elif 0 <= z and z <= k:
                ans += 1
    print(ans)

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

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

for i in range(K+1):
    for j in range(K+1):
        for q in range(K+1):
            if i+j+q == S:
                answer+=1
print(answer)

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

for i in range(K+1):
    for j in range(K+1):
        if 0 <= S-i-j and S-i-j <= K:
            answer+=1
print(answer)
# Original solution
import itertools
k, s = list(map(int, input().split()))

data = [i for i in range(k + 1)]
# print(data)
dd = itertools.product(data, repeat=3)
# print(dd)
dd = list(dd)

ans = 0
for i in dd:
    #print(sum(i))
    if (sum(i) == s):
        ans += 1

print(ans)


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

#data = [i for i in range(k + 1)]
# print(data)
#dd = itertools.product(data, repeat=3)
# print(dd)
#dd = list(dd)
#target = s / 3
ans = 0
if (k * 3 < s):

    pass
else:
    for x in range(0, k + 1):
        #temp = s - x
        # 2なら、（０、２）（１、１）（２、０）
        for y in range(0, k + 1):
            if (0 <= s - (x + y) <= k):
                ans += 1

print(ans)

'''
ans = 0
for i in dd:
    #print(sum(i))
    if (sum(i) == s):
        ans += 1

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

for i in range(k + 1):
    x = i
    for j in range(k + 1):
        y = j
        for l in range(k + 1):
            z = l
            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 (s - x - y >= 0 and s - x - y <= 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(x,k+1):
        for z in range(y,k+1):
            if x+y+z == s:
                if x==y==z:
                    cnt+=1
                elif (x==y and x!=z) or (x!=y and x==z) or (x!=y and y==z):
                    cnt+=3
                else:
                    cnt+=6
print(cnt)

# Optimized solution
k, s = list(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)
# Original solution
k, s = list(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)

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

cnt = 0

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

print(cnt)

# Optimized solution
K, S = 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)
# 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
                break

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 x + y <= s <= x + y + k:
            count += 1

print(count)
# Original solution
k,s = list(map (int ,input ().split ()))
x = 0
y = 0
z = 0
p = 0
while x <= k:
  while y <= k:
    while z <= k:
      if x+y+z == s:
        p += 1
      z += 1
    y += 1
    z = 0
  x += 1
  y,z = 0,0
print (p)

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

ret = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ret += 1
print(ret)                

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

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

def main():
    k,s = list(map(int,input().split()))
    counter=0

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


if __name__=="__main__":
    main()

# Optimized solution
#-*-coding:utf-8-*-

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

if __name__=="__main__":
    main2()
# Original solution
def actual(K, S):
    count = 0

    for x in range(S + 1):
        for y in range(S + 1):
            z = S - (x + y)

            cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
            cond2 = (x + y + z) == S

            if cond1 and cond2:
                count += 1

    return count

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

# Optimized solution
def actual(K, S):
    count = 0

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

            cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
            cond2 = (x + y + z) == S

            if cond1 and cond2:
                count += 1

    return count

K, S = list(map(int, input().split()))
print((actual(K, S)))
# Original solution
def actual(K, S):
    count = 0

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

            cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
            cond2 = (x + y + z) == S

            if cond1 and cond2:
                count += 1

    return count

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

# Optimized solution
def actual(K, S):
    count = 0

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

            if 0 <= z <= K:
                count += 1

    return count

K, S = list(map(int, input().split()))
print((actual(K, S)))
# Original solution
a,b=list(map(int,input().split()))
count=0
for x in range(a+1):
    for y in range(a+1):
        for z in range(a+1):
            if x+y+z == b:
                count+=1
print(count)

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

count = int(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
k, s = list(map(int, input().split()))

count = int(0)

for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <= k:
            count += 1
print(count)
# Original solution
k, s = [int(i) for i in input().split()]

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

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

ans = 0
for i in range(k+1):
  for j in range(k+1):
    if k >= s-i-j and s-i-j>=0:
      ans += 1
        
print(ans)
# Original solution
K,S=[int(i) for i in input().split()]
count=0
for i in range(0,K+1):
        for j in range(0,K+1):
            for k in range(0,K+1):
                 if i+j+k==S:
                    count+=1
print(count)

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

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




# Optimized solution
#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 = 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>=0 and z <= k):
            #print(x,y,z)
            ans += 1
print(ans)
# Original solution

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

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

print(wariate)

# 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)
        cnt += (0 <= z <= K)

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):
        z = S - (x + y)
        cnt += (0 <= z <= K)

print(cnt)

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

for x in range(K + 1):
    S2 = S - x
    if S2 < 0:
        break
    elif S2 > 2*K:
        continue
    else:
        cnt += (S2 + 1) - 2*max(0, S2 - K)

print(cnt)
# Original solution
k,s=list(map(int,input().split()))
print(([x+y+z for z in range(k+1) for y in range(k+1) for x in range(k+1)].count(s)))

# Optimized solution
k,s=list(map(int,input().split()))
ans=0
for i in range(k+1):
    x=min(s-i,k)-max(0,s-k-i)
    if x>=0:
        ans+=x+1
print(ans)
# Original solution
[k,s]=[int(i) for i in input().split()]
a=[]
for i in range(k+1):
    x=i
    for j in range(s-x+1):
        y=s-x-j
        z=s-x-y
        if y<=k and z<=k:
            a.append([x,y,z])
#print(a)
print((len(a)))

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

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