#coding:utf-8

#1_7_B 2015.4.5

while True:

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

    if n == x == 0:

        break

    count = 0

    

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

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

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

                if i + j + k == x and i < j < k:

                    count += 1

    print(count)
#coding:utf-8

#1_7_B 2015.4.5

while True:

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

    if n == x == 0:

        break

    count = 0

    

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

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

            if (x - i - j) <= n and i < j < (x - i -j):

                count += 1

    print(count)
# coding:utf-8
# 1_7_B 2015.4.5
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            for k in range(1, n + 1):
                if i + j + k == x and i < j < k:
                    count += 1
    print(count)

# coding:utf-8
# 1_7_B 2015.4.5
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if (x - i - j) <= n and i < j < (x - i - j):
                count += 1
    print(count)

-            for k in range(1, n + 1): -                if i + j + k == x and i < j < k: -                    count += 1 +            if (x - i - j) <= n and i < j < (x - i - j): +                count += 1