while 1:

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

 if n+x==0:break

 print((len([1 for i in range(1,x//3)for j in range(i+1,n)if j<x-i-j<=n])))
while 1:

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

 if n+x==0:break

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

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

-            len( +            sum( -                    1 -                    for i in range(1, x // 3) -                    for j in range(i + 1, n) -                    if j < x - i - j <= n +                    max(0, (x - a - 1) // 2 - max(a, x - a - 1 - n)) +                    for a in range(1, x // 3)