while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for a in range(n + 1):
        for b in range(1, a):
            for c in range(1, b):
                if a + b + c == x:
                    count += 1
    print(count)

d28f4a8b66bfcc2947fa40d4574c17cb677e545f
<mask token>

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for a in range(n + 1):
        for b in range(1, a):
            for c in range(1, b):
                if a + b + c == x:
                    count += 1
    print(count)
