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

count = 0

for X in range(K + 1):

    for Y  in range(K + 1):

        Z = S - X - Y

        if 0 <= Z and Z <= K:

            count += 1

print(count)
def main():

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

    ans = sum([1 for X in range(K+1) for Y in range(K+1) if S-X-Y>=0 and S-X-Y<=K])

    print(ans)

if __name__ == "__main__":

    main()
K, S = list(map(int, input().split()))
count = 0
for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z and Z <= K:
            count += 1
print(count)

def main():
    K, S = list(map(int, input().split()))
    ans = sum(
        [
            1
            for X in range(K + 1)
            for Y in range(K + 1)
            if S - X - Y >= 0 and S - X - Y <= K
        ]
    )
    print(ans)


if __name__ == "__main__":
    main()

-K, S = list(map(int, input().split())) -count = 0 -for X in range(K + 1): -    for Y in range(K + 1): -        Z = S - X - Y -        if 0 <= Z and Z <= K: -            count += 1 -print(count) +def main(): +    K, S = list(map(int, input().split())) +    ans = sum( +        [ +            1 +            for X in range(K + 1) +            for Y in range(K + 1) +            if S - X - Y >= 0 and S - X - Y <= K +        ] +    ) +    print(ans) + + +if __name__ == "__main__": +    main()