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()
def main():

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

    ans = 0

    for X in range(K+1):

        Y_min = max(0, S-X-K)

        Y_max = min(K, S-X)

        ans += max(0, Y_max - Y_min + 1)

    print(ans)

if __name__ == "__main__":

    main()
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()

def main():
    K, S = list(map(int, input().split()))
    ans = 0
    for X in range(K + 1):
        Y_min = max(0, S - X - K)
        Y_max = min(K, S - X)
        ans += max(0, Y_max - Y_min + 1)
    print(ans)


if __name__ == "__main__":
    main()

-    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 -        ) -    ) +    ans = 0 +    for X in range(K + 1): +        Y_min = max(0, S - X - K) +        Y_max = min(K, S - X) +        ans += max(0, Y_max - Y_min + 1)