while 1:

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

 if n+x==0:break

 c=0

 for i in range(3,n+1):

  for j in range(2,x-i):

   if x-i-j<j<i:

    c+=1

 print(c)
while 1:

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

 if n+x==0:break

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

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

-    c = 0 -    for i in range(3, n + 1): -        for j in range(2, x - i): -            if x - i - j < j < i: -                c += 1 -    print(c) +    print( +        ( +            sum( +                [ +                    1 +                    for i in range(3, n + 1) +                    for j in range(2, x - i) +                    if x - i - j < j < i +                ] +            ) +        ) +    )