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)

def slove():

    import sys

    input = sys.stdin.readline

    k, s = list(map(int, input().rstrip('\n').split()))

    cnt = 0

    for i in range(k + 1):

        for j in range(k + 1):

            if i + j > s:

                break

            else:

                n = s - i - j

                if 0 <= n <= k:

                    cnt += 1

    print(cnt)





if __name__ == '__main__':

    slove()

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)

def slove():
    import sys

    input = sys.stdin.readline
    k, s = list(map(int, input().rstrip("\n").split()))
    cnt = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if i + j > s:
                break
            else:
                n = s - i - j
                if 0 <= n <= k:
                    cnt += 1
    print(cnt)


if __name__ == "__main__":
    slove()

-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) +def slove(): +    import sys + +    input = sys.stdin.readline +    k, s = list(map(int, input().rstrip("\n").split())) +    cnt = 0 +    for i in range(k + 1): +        for j in range(k + 1): +            if i + j > s: +                break +            else: +                n = s - i - j +                if 0 <= n <= k: +                    cnt += 1 +    print(cnt) + + +if __name__ == "__main__": +    slove()