import sys

import os





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    K, S = list(map(int, sys.stdin.readline().split()))



    ret = 0

    for x in range(K + 1):

        for y in range(K + 1):

            if S - x - y <= K and S - x - y >= 0:

                ret += 1

    print(ret)





if __name__ == '__main__':

    main()

import sys

import os

import math



ii = lambda: int(sys.stdin.buffer.readline().rstrip())

il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))

iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]



iss = lambda: sys.stdin.buffer.readline().decode().rstrip()

sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))

isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]



MOD = 10 ** 9 + 7





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    K, S = il()

    P = [1 for x in range(K + 1) for y in range(K + 1) if 0 <= S - x - y <= K]

    print((sum(P)))





if __name__ == '__main__':

    main()

import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    K, S = list(map(int, sys.stdin.readline().split()))
    ret = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - x - y <= K and S - x - y >= 0:
                ret += 1
    print(ret)


if __name__ == "__main__":
    main()

import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
MOD = 10**9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    K, S = il()
    P = [1 for x in range(K + 1) for y in range(K + 1) if 0 <= S - x - y <= K]
    print((sum(P)))


if __name__ == "__main__":
    main()

+import math + +ii = lambda: int(sys.stdin.buffer.readline().rstrip()) +il = lambda: list(map(int, sys.stdin.buffer.readline().split())) +fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) +iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] +iss = lambda: sys.stdin.buffer.readline().decode().rstrip() +sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) +isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] +MOD = 10**9 + 7 -    K, S = list(map(int, sys.stdin.readline().split())) -    ret = 0 -    for x in range(K + 1): -        for y in range(K + 1): -            if S - x - y <= K and S - x - y >= 0: -                ret += 1 -    print(ret) +    K, S = il() +    P = [1 for x in range(K + 1) for y in range(K + 1) if 0 <= S - x - y <= K] +    print((sum(P)))