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)

import sys

def input():

  return sys.stdin.readline().rstrip()



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)

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)

import sys


def input():
    return sys.stdin.readline().rstrip()


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)

+import sys + + +def input(): +    return sys.stdin.readline().rstrip() + + -ans = 0 +cnt = 0 -            ans += 1 -print(ans) +            cnt += 1 +print(cnt)