k, s = [int(x) for x in input().split()]

cnt = 0

for x in range(k + 1):

    if x > s:

        continue

    for y in range(x, k + 1):

        if y > s:

            break

        z = s - x - y

        if y <= z and z <= k:

            if x + y + z == s:

                if x == y == z:

                    cnt += 1

                elif x == y or y == z:

                    cnt += 3

                else:

                    cnt += 6

print(cnt)

def solve():

    K, S = [int(x) for x in input().split()]

    res = 0

    for x in range(K + 1):

        for y in range(K + 1):

            z = S - x - y

            if 0 <= z <= K:

                res += 1

    return res



if __name__ == '__main__':

    print((solve()))

k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)

def solve():
    K, S = [int(x) for x in input().split()]
    res = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 <= z <= K:
                res += 1
    return res


if __name__ == "__main__":
    print((solve()))

-k, s = [int(x) for x in input().split()] -cnt = 0 -for x in range(k + 1): -    if x > s: -        continue -    for y in range(x, k + 1): -        if y > s: -            break -        z = s - x - y -        if y <= z and z <= k: -            if x + y + z == s: -                if x == y == z: -                    cnt += 1 -                elif x == y or y == z: -                    cnt += 3 -                else: -                    cnt += 6 -print(cnt) +def solve(): +    K, S = [int(x) for x in input().split()] +    res = 0 +    for x in range(K + 1): +        for y in range(K + 1): +            z = S - x - y +            if 0 <= z <= K: +                res += 1 +    return res + + +if __name__ == "__main__": +    print((solve()))