def get_num(n, m):

    ans = 0

    for x in range(n, 2, -1):

        if 3 * x - 2 < m:

            return ans

        for y in range(x - 1, 1, -1):

            if x + 2 * y - 1 < m:

                break

            for z in range(y - 1, 0, -1):

                s = x + y + z

                if s == m:

                    ans += 1

                    break 

    return ans





while True:

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

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

        break

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

    ans = 0

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

        for y in range(x - 1, 1, -1):

            if x + 2 * y - 1 < m:

                break

            for z in range(y - 1, 0, -1):

                s = x + y + z

                if s == m:

                    ans += 1

                    break

    return ans





while True:

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

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

        break

    print((get_num(n, x)))
def get_num(n, m):
    ans = 0
    for x in range(n, 2, -1):
        if 3 * x - 2 < m:
            return ans
        for y in range(x - 1, 1, -1):
            if x + 2 * y - 1 < m:
                break
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s == m:
                    ans += 1
                    break
    return ans


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

def get_num(n, m):
    ans = 0
    for x in range(min(n, m), (m + 2) / 3, -1):
        for y in range(x - 1, 1, -1):
            if x + 2 * y - 1 < m:
                break
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s == m:
                    ans += 1
                    break
    return ans


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

-    for x in range(n, 2, -1): -        if 3 * x - 2 < m: -            return ans +    for x in range(min(n, m), (m + 2) / 3, -1): -    [n, m] = [int(x) for x in input().split()] -    if [n, m] == [0, 0]: +    [n, x] = [int(m) for m in input().split()] +    if [n, x] == [0, 0]: -    print((get_num(n, m))) +    print((get_num(n, x)))