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(x,k+1):
        for z in range(y,k+1):
            if x+y+z == s:
                if x != y != z :
                    ans += 6
                elif x == y != z or x != y == z:
                    ans += 3
                elif 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 0 <= s-x-y <= 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):
        if x + y > S:
            break
        for z in range(K+1):
            if x + y + z > S:
                break

            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):
        x_y = x + y
        if x_y > S:
            break
        if S - x_y <= 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):
        if 0<=S-X-Y<=K:
            count+=1
                
print(count)
# Original solution
import sys

"""テンプレ"""

# 高速
input = sys.stdin.readline

# 1行を空白でリストにする(int)
def intline():
    return list(map(int, input().split()))


# 上のstrヴァージョン
def strline():
    return list(map(str, input().split()))


# 1列に並んだ数
def intlines(n):
    return [int(eval(input()) for _ in range(n))]


# 上の文字列ヴァージョン
def lines(n):
    return [eval(input()) for _ in range(n)]
    

# Union-Find木  http://at274.hatenablog.com/entry/2018/02/02/173000
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


# 重み付きのUnion-Find木　http://at274.hatenablog.com/entry/2018/02/03/140504
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]




"""ここからメインコード"""

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


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

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

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

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

ans = 0

for x in range(max(0, S - 2 * K), min(K, S) + 1):
    ans += min(K, S - x) - max(0, S - x - K) + 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):    
        if s-(x+y) <= k and  s-(x+y) >= 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):
    Z=S-X-Y
    if Z in range(K+1):
      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 and 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):
        ans+=1 if K>=S-(x+y)>=0 else 0
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):
        for k in range(K+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):
        k=S-i-j
        if i+j+k==S:
            if 0<=k<=K:
                ans+=1
print(ans)
# Original solution
k,s=list(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
    for z in range(k+1):
      if x+y+z==s: c+=1
      if x+y+z>s: break
print(c)


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

ans = 0

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

print(ans)


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

#これは立方体の中のどこか一点を選ぶ問題とみなせる
#その中で選ばれた座標の各要素の和が、Sに等しければ良い
#点の総和は(K+1)*3個あり（※ゼロを含むから）、それらが選択可能なx,y,zの集合である
#x,y,zの和がSに達しない場合は、Sを満たす集合はその立方体の外側にある

L=[]
counter=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            L.append([x,y,z])
            if (S==x+y+z):counter+=1

print(counter)

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

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

ans = 0

for i in range(k+1):
    for j in range(i,k+1):
        for c in range(j,k+1):
            if i + j + c == s:
                if i == j and j == c:
                    ans += 1
                elif i!=j and j!=c and c!=j:
                    ans += 6
                else:
                    ans += 3
print(ans)


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

ans = 0

for i in range(k+1):
    for j in range(i,k+1):
        c = s-i-j
        if k >= c and c >=j:
            if i == j and j == c:
                ans += 1
            elif i!=j and j!=c and c!=j:
                ans += 6
            else:
                ans += 3
        
print(ans)
# Original solution
k,s=list(map(int,input().split()))
cnt=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:
                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):
        z = s-x-y
        if z >= 0 and z <= k:
            cnt+=1
print(cnt)
# Original solution
import bisect
K, S = list(map(int,input().split()))
listK = [i for i in range(K+1)]
list2K = [i for i in range(K**2)]
ans = 0
for i in range(K+1):
    id = bisect.bisect_left(list2K,S-i)
    if id < len(list2K) and list2K[id] == S-i:
        for j in range(K+1):
            id2 = bisect.bisect_left(listK,list2K[id]-j)
            if id2 < len(listK) and listK[id2] == list2K[id]-j:
                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 itertools
k,s=list(map(int,input().split()))
x=(x for x in range(0,k+1))
y=(y for y in range(0,k+1))
z=(z for z in range(0,k+1))
data=list(itertools.product(x,y,z))
ans=[sum(i) for i in (data)]
print((ans.count(s)))


# 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
import itertools
k, s = list(map(int, input().split()))
lst1 = [x for x in range(k+1)]
lst2 = [x for x in range(k+1)]
lst3 = [x for x in range(k+1)]
data = list(itertools.product(lst1, lst2, lst3))
lst4 = [sum(i) for i in (data)]
print((lst4.count(s)))


# 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):
    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 and x+y+z == s:
            ans += 1
print(ans)
# Original solution
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

    c = 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:
                    break
                if i + j + l == s:
                    c += 1
                    # print(i, j, l)

    print(c)


if __name__ == '__main__':
    main()


# Optimized solution
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

    c = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if i + j > s:
                break
            if s-i-j <= k:
                c += 1

    print(c)


if __name__ == '__main__':
    main()
# Original solution
k, s = list(map(int, input().split()))
# print(k, s)
count = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            # print(x, y, z)
            if x + y + z == s:
                count += 1
print(count)

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

rcount = 0

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

print(rcount)


# 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 >= 0 and z <= 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):
    for k in range(K+1):
      if i+j+k == 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):
    k = S - i -j
    if 0 <= k and k <= 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()))
ans = sum(0 <= S-x-y <= K for x in range(K+1) for y in range(K+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):
    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 <= k:
            ans += 1
print(ans)
# Original solution
# Sum of Three Integers
import sys

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

def getAns(k, s) :
    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
    return cnt
print((getAns(K, S)))

# Optimized solution
# Sum of Three Integers
import sys

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

def getAns(k, s) :
    cnt = 0
    for x in range(k + 1) :
        for y in range(k + 1) :
            z = s - x - y
            if 0 <= z <= k :
                cnt += 1
    return cnt
print((getAns(K, S)))
# 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 i in range(K+1):
    for t in range(i,K+1):
        for s in range(t,K+1):
            if i+t+s==S:
                if i==t==s:
                    cnt+=1
                elif i==t or i==s or t==s:
                    cnt+=3
                else:
                    cnt+=6
            else:
                continue
print(cnt)

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


count = 0
for x in range(K+1):
    if x > S :
        break
    elif S - x > 2*K:
        continue
    for y in range(K+1):
        if x + y > S:
            break
        elif S - (x+y) > K:
            continue
        for z in range(K+1):
            if x + y + z > S:
                break
            elif x + y + z == S:
                count +=1
print(count)


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


count = 0
for x in range(K+1):
    if x > S :
        break
    elif S - x > 2*K:
        continue
    for y in range(K+1):
        if x + y > S:
            break
        elif S - (x+y) > K:
            continue
        count+= 1
print(count)
# Original solution
def resolve():
    K, S = list(map(int, input().split()))
    print((
        len(
            [
                (x, y, z)
                for x in range(K + 1)
                for y in range(K + 1)
                for z in range(K + 1)
                if x + y + z == S and max(x, y, z) <= K
            ]
        )
    ))


if __name__ == "__main__":
    resolve()

# Optimized solution
def resolve():
    K, S = list(map(int, input().split()))
    count = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - K <= x + y <= S and max(x, y) <= K:
                count += 1
    print(count)


if __name__ == "__main__":
    resolve()
# Original solution
def resolve():
    K, S = list(map(int, input().split()))
    count = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - K <= x + y <= S and max(x, y) <= K:
                count += 1
    print(count)


if __name__ == "__main__":
    resolve()

# Optimized solution
def resolve():
    K, S = list(map(int, input().split()))
    count = 0
    for x in range(K + 1):
        for y in range(max(0, S - K - x), min(K + 1, S - x + 1)):
            count += 1
    print(count)


if __name__ == "__main__":
    resolve()
# Original solution
k, s = list(map(int, input().split()))
count=0
if k < s/3:
  print((0))
  quit()
for a in range(0, k+1):
  if a == s:
    print((count+1))
    quit()
  for b in range(0, k+1):
    if a+b == s:
      count+=1
      break
    elif a+b > s:
      break
    for c in range(0, k+1):
      if a+b+c == s:
        count+=1
      elif a+b+c > s:
        break
print(count)

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

print(cnt)
# Original solution
k,s = list(map(int, input().split()))
c = 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:
          c += 1
        elif (x == y and y != z) or (x != y and y == z):
          c += 3
        else:
          c += 6
print(c)

# Optimized solution
k,s = list(map(int, input().split()))
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
def binary_search_list(beSearched,wanted) :
    l = 0
    r = len(beSearched)

    #print("condition = {}".format(r-l))

    while r - l >= 1 :
        s = (l + r) // 2
        #print("l={} r={} s={}".format(l,r,s))
        if beSearched[s] == wanted :
            return True
        if beSearched[s] > wanted :
            r = s
        else :
            l = s + 1

    return False

K,S = (int(_) for _ in input().split())
num = [_ for _ in range(K+1)]
out = 0
for i in range(K+1):
    for j in range(i+1):
        #print(num[:j+1])
        b = binary_search_list(num[:j+1],S - i - j)
        #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j))
        if b :
            if i == j and j == S - i - j:
                out += 1
            elif i == j or j == S - i - j or S -i - j == i:
                out += 3
            else :
                out += 6

print(out)


# Optimized solution
def binary_search_list(beSearched,wanted) :
    l = 0
    r = len(beSearched)

    #print("condition = {}".format(r-l))

    while r - l >= 1 :
        s = (l + r) // 2
        #print("l={} r={} s={}".format(l,r,s))
        if beSearched[s] == wanted :
            return True
        if beSearched[s] > wanted :
            r = s
        else :
            l = s + 1

    return False

K,S = (int(_) for _ in input().split())
num = [_ for _ in range(K+1)]
out = 0
for i in range(K+1):
    for j in range(i+1):
        if 0 <= S - i - j <= j :
            if i == j and j == S - i - j:
                out += 1
            elif i == j or j == S - i - j or S -i - j == i:
                out += 3
            else :
                out += 6
        #print(num[:j+1])
        #b = binary_search_list(num[:j+1],S - i - j)
        #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j))
        #if b :
            #if i == j and j == S - i - j:
                #out += 1
            #elif i == j or j == S - i - j or S -i - j == i:
                #out += 3
            #else :
                #out += 6

print(out)
# Original solution
# N

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

K+=1

count=0
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i + j + k == S:
                count+=1
#                 print(i,j,k)
print(count)

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

K+=1

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

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

ans = 0
for z in range(min(k, s)+1):
    ans += max(0, min(s-z, k)+1-(max(0, s-z-k)))
print(ans)


# Optimized solution
k, s = list(map(int, input().split()))
print((sum([max(0, min(s-z, k)+1-max(0, s-z-k)) for z in range(min(k, s)+1)])))