CodeEff/ECCO huggingface dataset:
# 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 <= K:
			Ans += 1

print(Ans)
# 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):
      tot = i+j+l
      if s == tot:
        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):
    l = s-i-j
    if l>=0 and l<=k:
      count +=1
print(count)
# Original solution
K,S=list(map(int,input().split()))
O=0
for X in range(K+1):
  for Y in range(K+1):
    Z=S-X-Y
    if 0<=Z<=K:
      O+=1
print(O)


# 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()))
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):
        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):
        z = s - (x + y)
        if (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 not (0 <= z <= k):
            continue
        cnt += 1
print(cnt)
# Original solution
K, S = [int(i) for i in input().split()]
l = []

for x in range(K + 1):
    if S - x >= 0:
        for y in range(K + 1):
            if K >= S - x - y >= 0:
                z = S - x - y
                l.append((x, y, z))


print((len(l)))

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

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

print(ans)
# Original solution
import sys

input = sys.stdin.readline


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


def il():
    return list(map(int, input().split()))


K, S = il()
c = 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
import sys

input = sys.stdin.readline


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


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= (S - (x + y)) <= K:
            c += 1
print(c)
# 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().split()))

count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == 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 z <= K and z >= 0:
            count += 1

print(count)
# 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 x+y+z==s:
                count+=1
print(count)


# Optimized solution

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

count=0

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

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

count = 0
for x,y,z in [(x,y,z) 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:
        count += 1

print(count)

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

count = 0
for x,y in [(x,y) for x in range(0,K + 1) for y in range(0,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 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 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()))

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):
        z = S - x - y
        if z >= 0 and z <= K:
            cnt += 1
print(cnt)
# 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):
            if i + j + k == 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):
        k = S - i -j
        if 0 <= k <= K: 
            count += 1
print(count)
# Original 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)

# Optimized solution
# coding: utf-8
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
# -*- coding: utf-8 -*-
# problem B

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 and z <=k:
            ans = ans+1

print(ans)

# Optimized solution
#!/usr/bin/env python

def main():
    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:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# 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
"""
Y+Z=S−X  が成り立つことは分かるものの1通りには決まりません。
満たすべき条件は 0≤Y,Z≤K と Y+Z=S−X なので、変数 Z を消去すると以下の不等式が得られます。

0≤Y≤K
0≤Z=S−Y−X≤K
変形して、Y≤S−X かつ S−X−K≤Y

つまり Y の下限は Ymin=max(0,S−X−K) 、
上限は Ymax=min(K,S−X) となります。

"""

K, S = list(map(int, input().split()))
ans = 0
for x in range(K+1):
  mn = max(0, S-x-K)
  mx = min(K, S-x)
  ans += max(0, mx-mn+1)
print(ans)
# Original solution
K, S = list(map(int, input().split()))

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

print(kotae)

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

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

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

# Optimized solution
k,s = list(map(int,input().split()))
f = 0
for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if 0 <= l <=k:
            f+=1
print(f)
# 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 s-x-y <= k and s-x-y>=0:
        ans += 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 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
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    if i > S:
        break
    # Y
    for j in range(K + 1):
        if i + j > S:
            break
        # Z
        for k in range(K + 1):
            if i + j + k > S:
                break
            if i + j + k == S:
                cnt += 1
print(cnt)


# Optimized solution
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            cnt += 1
print(cnt)
# Original solution
# -*- coding: utf-8 -*-

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

# 絶対TLE…
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
# -*- coding: utf-8 -*-

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

ans = 0
for x in range(K+1):
    for y in range(K+1):
        # zは全部回さないで、Sを満たすようなものだけ用意する
        z = S - x - y
        # 候補となるzがKの範囲内であれば有効
        if 0 <= z <= 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
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()))

ans = 0

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

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

count = 0
num = list(range(k+1))
for x in num:
  for y in num:
    if x + y > s:
      break
    for z in num:
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        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:
      break
    a = s - x - y
    if a >= 0 and a <= k:
      count += 1

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

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

print(cnt)
# Original solution
K,S = list(map(int, input().split()))
ret = 0
for A in range(S+1):
    if A > K: continue
    for B in range(S+1-A):
        if B > K:continue
        # print(A,B,S-A-B)
        if S-A-B <= K: 
            # print(A,B,S-A-B)
            ret += 1
print(ret)

# Optimized solution
K,S = list(map(int, input().split()))
# debug
# print([(A,B,S-A-B) for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K])
print((sum(1 for A in range(K+1) for B in range(K+1) if 0 <= S-A-B <= K)))
# Original solution
from collections import defaultdict


def main():
    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)


if __name__ == '__main__':
    main()


# Optimized solution
from collections import defaultdict


def main():
    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)


if __name__ == '__main__':
    main()
# 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()))
print((len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k])))
# Original solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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


# Optimized solution
import sys

stdin = sys.stdin
na = lambda: list(map(int, stdin.readline().split()))

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

count = 0

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

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

print(count)

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

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

print(count)
# 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):
		if 0 <= s-x-y <= k:
			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
def resolve():
    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)
resolve()

# Optimized solution
def resolve():
    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)
resolve()
# Original solution
K, S = list(map(int, input().split()))
import itertools
count = 0
for pattern in list(itertools.product(list(range(K+1)), repeat=2)):
    #print(pattern)
    if S-K <= sum(pattern) <= S:
        
        count += 1

print(count)

# Optimized solution
K, S = list(map(int, input().split()))
import itertools
count = 0
for pattern in itertools.product(list(range(K+1)), repeat=2):
    #print(pattern)
    if S-K <= sum(pattern) <= S:
        
        count += 1

print(count)
# Original solution
K, S = list(map(int, input().split()))
import itertools
count = 0
for pattern in itertools.product(list(range(K+1)), repeat=2):
    #print(pattern)
    if S-K <= sum(pattern) <= S:
        
        count += 1

print(count)


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

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


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

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

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

import itertools

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

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

print(count)

# 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()))
a=0
for x in range(k+1):
  for y in range (x+1):
    for z in range (y+1):
      if x + y + z == s and x!=y and y!=z and z!=x:
          a+=6
      elif x+y+z==s and x==y and x!=z:
          a+=3
      elif x+y+z==s and y==z and x!=y:
          a+=3
      elif x+y+z==s and x==z and x!=y:
          a+=3
      elif x+y+z==s and x==y and y==z:
          a+=1
          break
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 0<=s-x-y<=k:
            a+=1
print(a)
# Original solution
import itertools

max_range, sum_ = list(map(int, input().split()))

count = 0
for x, y, z in itertools.combinations_with_replacement(list(range(max_range + 1)), r=3):
    if x + y + z == sum_:
        len_set = len({x, y, z})
        if len_set == 1:
            count += 1
        elif len_set == 2:
            count += 3
        else:
            count += 6

print(count)


# Optimized solution
max_range, sum_ = list(map(int, input().split()))

count = 0
for x in range(0, min(max_range + 1, sum_ + 1)):
    for y in range(0, min(max_range + 1, sum_ - x + 1)):
        if sum_ - x - y <= max_range:
            count += 1

print(count)
# Original solution
K,S = list(map(int,input().split()))
count = 0
for i in range(K+1):
    if i == S:
        count += 1
        break
    for j in range(K+1):
        if i + j == S:
            count += 1
            break
        for k in range(K+1):
            if i+j+k == 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()))
 
cnt = 0
for i in range(K+1):
    flg = False
    for j in range(K+1):
        if flg == True:
            break
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                flg = True
                lim_tmp = min(K - j, k)
                cnt += lim_tmp + 1
                break
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):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)
# Original solution
# -*- coding: utf-8 -*-
def main():
	c = 0
	k, s = list(map(int, input().split()))
	#k, s = map(int, "2 2".split())
	for x in range(k + 1):
		for y in range(k + 1):
			for z in range(k + 1):
				if s == x + y + z:
					c += 1
	print(c)
	return

if __name__ == '__main__':
	main()


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