from itertools import combinations

while True:

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

    if n == x == 0:

        break

    cnt = 0

    for li in combinations(list(range(1, n + 1)), 3):

        if sum(li) == x:

            cnt += 1

    print(cnt)



from itertools import combinations

while True:

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

    if n == x == 0:

        break

    print((sum(1 for li in combinations(list(range(1, n + 1)), 3) if sum(li) == x)))

from itertools import combinations

while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    cnt = 0
    for li in combinations(list(range(1, n + 1)), 3):
        if sum(li) == x:
            cnt += 1
    print(cnt)

from itertools import combinations

while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print((sum(1 for li in combinations(list(range(1, n + 1)), 3) if sum(li) == x)))

-    cnt = 0 -    for li in combinations(list(range(1, n + 1)), 3): -        if sum(li) == x: -            cnt += 1 -    print(cnt) +    print((sum(1 for li in combinations(list(range(1, n + 1)), 3) if sum(li) == x)))