def get_num(n, x):

    ans = 0

    for n3 in range(min(n, x - 2), (x + 2) / 3, -1):

        for n2 in range(min(n3 - 1, x - n3 - 1), (x - n3 + 1) / 2 - 1, -1):

            for n1 in range(min(n2 - 1, x - n3 - n2), 0, -1):

                if n3 == x - n1 - n2:

                    ans += 1

                    break

    return ans





while True:

    [n, x] = [int(m) for m in input().split()]

    if [n, x] == [0, 0]:

        break

    if x < 3:

        print((0))

    else:

        print((get_num(n, x)))
def get_num(n, x):

    ans = 0

    for n3 in range(min(n, x - 3), (x + 2) / 3, -1):

        for n2 in range(min(n3 - 1, x - n3 - 1), (x - n3 + 1) / 2 - 1, -1):

            for n1 in range(min(n2 - 1, x - n3 - n2), 0, -1):

                if n3 == x - n1 - n2:

                    ans += 1

                    break

    return ans





data = []

while True:

    [n, x] = [int(m) for m in input().split()]

    if [n, x] == [0, 0]:

        break

    if x < 3:

        # print(0)

        data.append(0)

    else:

        # print(get_num(n, x))

        data.append(get_num(n, x))

for n in data:

    print(n)
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x - 2), (x + 2) / 3, -1):
        for n2 in range(min(n3 - 1, x - n3 - 1), (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(min(n2 - 1, x - n3 - n2), 0, -1):
                if n3 == x - n1 - n2:
                    ans += 1
                    break
    return ans


while True:
    [n, x] = [int(m) for m in input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        print((0))
    else:
        print((get_num(n, x)))

def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x - 3), (x + 2) / 3, -1):
        for n2 in range(min(n3 - 1, x - n3 - 1), (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(min(n2 - 1, x - n3 - n2), 0, -1):
                if n3 == x - n1 - n2:
                    ans += 1
                    break
    return ans


data = []
while True:
    [n, x] = [int(m) for m in input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        # print(0)
        data.append(0)
    else:
        # print(get_num(n, x))
        data.append(get_num(n, x))
for n in data:
    print(n)

-    for n3 in range(min(n, x - 2), (x + 2) / 3, -1): +    for n3 in range(min(n, x - 3), (x + 2) / 3, -1): +data = [] -        print((0)) +        # print(0) +        data.append(0) -        print((get_num(n, x))) +        # print(get_num(n, x)) +        data.append(get_num(n, x)) +for n in data: +    print(n)