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



c = 0

for X in range(K + 1):

    for Y in range(K + 1):

        Z = S - X - Y

        if 0 <= Z <= K:

            c += 1



print(c)
K, S = [int(i) for i in input().split()]



ans = 0

# X <= Y <= Zとしても一般性を失わない

for x in range(K + 1):

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

        z = S - x - y

        if z < y:

            break

        if z <= K:

            if x == y == z:

                ans += 1

            elif x == y or y == z or z == x:

                ans += 3

            else:

                ans += 6

print(ans)

K, S = [int(i) for i in input().split()]
c = 0
for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z <= K:
            c += 1
print(c)

K, S = [int(i) for i in input().split()]
ans = 0
# X <= Y <= Zとしても一般性を失わない
for x in range(K + 1):
    for y in range(x, K + 1):
        z = S - x - y
        if z < y:
            break
        if z <= K:
            if x == y == z:
                ans += 1
            elif x == y or y == z or z == x:
                ans += 3
            else:
                ans += 6
print(ans)

-c = 0 -for X in range(K + 1): -    for Y in range(K + 1): -        Z = S - X - Y -        if 0 <= Z <= K: -            c += 1 -print(c) +ans = 0 +# X <= Y <= Zとしても一般性を失わない +for x in range(K + 1): +    for y in range(x, K + 1): +        z = S - x - y +        if z < y: +            break +        if z <= K: +            if x == y == z: +                ans += 1 +            elif x == y or y == z or z == x: +                ans += 3 +            else: +                ans += 6 +print(ans)