def main():



    while True:

        n, x = tuple(map(int, input().split()))

        pattern = 0



        if n == x == 0:

            break

        else:

            for a in range(1, n+1):

                for b in range(1, a):

                    for c in range(1, b):

                        pattern += 1 if a + b + c == x and a > b > c else 0

            print(pattern)

                            



if __name__ == '__main__':

    main()

def divide_two(c, z):

    min_b = z // 2 + 1

    max_b = min(c-1, z-1)

    return max(max_b-min_b+1, 0)

    



num_set = []

cnt = 0

while True:

    n, x = list(map(int, input().split()))

    if (n, x) == (0, 0):

        break

    else:

        num_set.append((n, x))

        cnt += 1



for i in range(cnt):

    num_count = 0

    (n, x) = num_set[i]

    for c in range(x//3, n+1):

        num_count += divide_two(c, x-c)

    print(num_count)

def main():
    while True:
        n, x = tuple(map(int, input().split()))
        pattern = 0
        if n == x == 0:
            break
        else:
            for a in range(1, n + 1):
                for b in range(1, a):
                    for c in range(1, b):
                        pattern += 1 if a + b + c == x and a > b > c else 0
            print(pattern)


if __name__ == "__main__":
    main()

def divide_two(c, z):
    min_b = z // 2 + 1
    max_b = min(c - 1, z - 1)
    return max(max_b - min_b + 1, 0)


num_set = []
cnt = 0
while True:
    n, x = list(map(int, input().split()))
    if (n, x) == (0, 0):
        break
    else:
        num_set.append((n, x))
        cnt += 1
for i in range(cnt):
    num_count = 0
    (n, x) = num_set[i]
    for c in range(x // 3, n + 1):
        num_count += divide_two(c, x - c)
    print(num_count)

-def main(): -    while True: -        n, x = tuple(map(int, input().split())) -        pattern = 0 -        if n == x == 0: -            break -        else: -            for a in range(1, n + 1): -                for b in range(1, a): -                    for c in range(1, b): -                        pattern += 1 if a + b + c == x and a > b > c else 0 -            print(pattern) +def divide_two(c, z): +    min_b = z // 2 + 1 +    max_b = min(c - 1, z - 1) +    return max(max_b - min_b + 1, 0) -if __name__ == "__main__": -    main() +num_set = [] +cnt = 0 +while True: +    n, x = list(map(int, input().split())) +    if (n, x) == (0, 0): +        break +    else: +        num_set.append((n, x)) +        cnt += 1 +for i in range(cnt): +    num_count = 0 +    (n, x) = num_set[i] +    for c in range(x // 3, n + 1): +        num_count += divide_two(c, x - c) +    print(num_count)