while 1:

    ans=0

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

    if n:

        for i in range(1,n-1):

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

                for k in range(j+1,n+1):

                    if i+j+k==x:ans+=1

    else:break

    print(ans)
while 1:

    a=0

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

    if n==0:break

    for i in range(1,n-1):

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

            c=x-i-j

            if c>j and c<=n:a+=1

    print(a)
while 1:
    ans = 0
    n, x = list(map(int, input().split()))
    if n:
        for i in range(1, n - 1):
            for j in range(i + 1, n):
                for k in range(j + 1, n + 1):
                    if i + j + k == x:
                        ans += 1
    else:
        break
    print(ans)

while 1:
    a = 0
    n, x = list(map(int, input().split()))
    if n == 0:
        break
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            c = x - i - j
            if c > j and c <= n:
                a += 1
    print(a)

-    ans = 0 +    a = 0 -    if n: -        for i in range(1, n - 1): -            for j in range(i + 1, n): -                for k in range(j + 1, n + 1): -                    if i + j + k == x: -                        ans += 1 -    else: +    if n == 0: -    print(ans) +    for i in range(1, n - 1): +        for j in range(i + 1, n): +            c = x - i - j +            if c > j and c <= n: +                a += 1 +    print(a)