#ABC51-B



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

sum=0

count=0

for i in range(K+1):

    sum+=i

    a=sum

    L=S-sum

    #print(L)

    LL=min(L,K)

    for j in range(LL+1):

        sum+=j

        if S-sum>=0 and S-sum<=K :

            count+=1

            #print(str(i)+" "+str(j))

        sum=a #jを足す前に戻す

    sum=0

print(count)          
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)
# ABC51-B
K, S = list(map(int, input().split()))
sum = 0
count = 0
for i in range(K + 1):
    sum += i
    a = sum
    L = S - sum
    # print(L)
    LL = min(L, K)
    for j in range(LL + 1):
        sum += j
        if S - sum >= 0 and S - sum <= K:
            count += 1
            # print(str(i)+" "+str(j))
        sum = a  # jを足す前に戻す
    sum = 0
print(count)

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)

-# ABC51-B -K, S = list(map(int, input().split())) -sum = 0 -count = 0 -for i in range(K + 1): -    sum += i -    a = sum -    L = S - sum -    # print(L) -    LL = min(L, K) -    for j in range(LL + 1): -        sum += j -        if S - sum >= 0 and S - sum <= K: -            count += 1 -            # print(str(i)+" "+str(j)) -        sum = a  # jを足す前に戻す -    sum = 0 -print(count) +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)