while True:

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



    if n==x==0: break



    print((sum( [ len(list(range(max(i+1,x-i-n),min(n,(x-i+1)//2)))) for i in range(1,min(n-1,x//3)) ])))
while True:

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



    if n==0 and x==0:

        break



    print((sum( [ max(min(n,(x-i+1)//2) - max(i+1,x-i-n),0) for i in range(1,min(n-1,x//3)) ])))
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print(
        (
            sum(
                [
                    len(list(range(max(i + 1, x - i - n), min(n, (x - i + 1) // 2))))
                    for i in range(1, min(n - 1, x // 3))
                ]
            )
        )
    )

while True:
    n, x = list(map(int, input().split()))
    if n == 0 and x == 0:
        break
    print(
        (
            sum(
                [
                    max(min(n, (x - i + 1) // 2) - max(i + 1, x - i - n), 0)
                    for i in range(1, min(n - 1, x // 3))
                ]
            )
        )
    )

-    if n == x == 0: +    if n == 0 and x == 0: -                    len(list(range(max(i + 1, x - i - n), min(n, (x - i + 1) // 2)))) +                    max(min(n, (x - i + 1) // 2) - max(i + 1, x - i - n), 0)