import sys

sys.setrecursionlimit(1 << 25)

read = sys.stdin.readline

ra = range

enu = enumerate





def read_ints():

    return list(map(int, read().split()))





def read_a_int():

    return int(read())





def read_tuple(H):

    '''

    H is number of rows

    '''

    ret = []

    for _ in range(H):

        ret.append(tuple(map(int, read().split())))

    return ret





def read_col(H):

    '''

    H is number of rows

    A列、B列が与えられるようなとき

    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合

    '''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return tuple(map(list, list(zip(*ret))))





def read_matrix(H):

    '''

    H is number of rows

    '''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return ret

    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため





MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

from collections import defaultdict, Counter, deque

from operator import itemgetter

from itertools import product, permutations, combinations

from bisect import bisect_left, bisect_right  # , insort_left, insort_right



# 全通り調べる問題

K, S = read_ints()

X = list(range(K + 1))  # Kは2500なのでK^2は間に合う

# X,Yについて全探索してZについて二分探索すればよい #連続なので範囲に入ってれば良い（二分探索もいらない！）

ans = 0

for x in X:

    for y in X:

        z = S - x - y

        if 0 <= z <= K:

            ans += 1

print(ans)

import sys

sys.setrecursionlimit(1 << 25)

readline = sys.stdin.buffer.readline

read = sys.stdin.readline  # 文字列読み込む時はこっち

ra = range

enu = enumerate





def exit(*argv, **kwarg):

    print(*argv, **kwarg)

    sys.exit()





def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))

# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと





def a_int(): return int(readline())





def ints(): return list(map(int, readline().split()))





def read_col(H):

    '''H is number of rows

    A列、B列が与えられるようなとき

    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, readline().split())))

    return tuple(map(list, zip(*ret)))





def read_tuple(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(tuple(map(int, readline().split())))

    return ret





def read_matrix(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, readline().split())))

    return ret

    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため





MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

from collections import defaultdict, Counter, deque

from operator import itemgetter, xor, add

from itertools import product, permutations, combinations

from bisect import bisect_left, bisect_right  # , insort_left, insort_right

from functools import reduce

from math import gcd





def lcm(a, b):

    # 最小公倍数

    g = gcd(a, b)

    return a // g * b





K, S = ints()

ans = 0

for x in range(K + 1):

    for y in range(K + 1):

        z = S - x - y

        if 0 <= z <= K:

            # print(x, y, z)

            ans += 1



print(ans)

import sys

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    """
    H is number of rows
    """
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    """
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    """
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, list(zip(*ret))))


def read_matrix(H):
    """
    H is number of rows
    """
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# 全通り調べる問題
K, S = read_ints()
X = list(range(K + 1))  # Kは2500なのでK^2は間に合う
# X,Yについて全探索してZについて二分探索すればよい #連続なので範囲に入ってれば良い（二分探索もいらない！）
ans = 0
for x in X:
    for y in X:
        z = S - x - y
        if 0 <= z <= K:
            ans += 1
print(ans)

import sys

sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1):
    return list(map(lambda x: x - sub, argv))


# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def a_int():
    return int(readline())


def ints():
    return list(map(int, readline().split()))


def read_col(H):
    """H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


K, S = ints()
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            # print(x, y, z)
            ans += 1
print(ans)

-read = sys.stdin.readline +readline = sys.stdin.buffer.readline +read = sys.stdin.readline  # 文字列読み込む時はこっち -def read_ints(): -    return list(map(int, read().split())) +def exit(*argv, **kwarg): +    print(*argv, **kwarg) +    sys.exit() -def read_a_int(): -    return int(read()) +def mina(*argv, sub=1): +    return list(map(lambda x: x - sub, argv)) + + +# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと +def a_int(): +    return int(readline()) + + +def ints(): +    return list(map(int, readline().split())) + + +def read_col(H): +    """H is number of rows +    A列、B列が与えられるようなとき +    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合""" +    ret = [] +    for _ in range(H): +        ret.append(list(map(int, readline().split()))) +    return tuple(map(list, zip(*ret))) -    """ -    H is number of rows -    """ +    """H is number of rows""" -        ret.append(tuple(map(int, read().split()))) +        ret.append(tuple(map(int, readline().split()))) -def read_col(H): -    """ -    H is number of rows -    A列、B列が与えられるようなとき -    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合 -    """ +def read_matrix(H): +    """H is number of rows""" -        ret.append(list(map(int, read().split()))) -    return tuple(map(list, list(zip(*ret)))) - - -def read_matrix(H): -    """ -    H is number of rows -    """ -    ret = [] -    for _ in range(H): -        ret.append(list(map(int, read().split()))) +        ret.append(list(map(int, readline().split()))) -from operator import itemgetter +from operator import itemgetter, xor, add +from functools import reduce +from math import gcd -# 全通り調べる問題 -K, S = read_ints() -X = list(range(K + 1))  # Kは2500なのでK^2は間に合う -# X,Yについて全探索してZについて二分探索すればよい #連続なので範囲に入ってれば良い（二分探索もいらない！） + +def lcm(a, b): +    # 最小公倍数 +    g = gcd(a, b) +    return a // g * b + + +K, S = ints() -for x in X: -    for y in X: +for x in range(K + 1): +    for y in range(K + 1): +            # print(x, y, z)