#!/usr/bin/env python

# -*- coding:utf-8 -*-

import timeit

import time

import sys

import io

import re

import math

#start = time.time()

#start = time.clock()

while True:

    l = []

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

    if n==x==0:

        break

    ans=0

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

        l.append(a)

    for i in l:

        if i > 98: break

        for j in l:

            if j > 99 or i+j>x: break

            p=0

            for k in l:

                p=i+j+k

                if (i != j and j != k and k != i) and p==x and i<j<k:

                    ans+=1

    print(ans)



#end = time.clock()

#print end - start
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)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import timeit
import time
import sys
import io
import re
import math

# start = time.time()
# start = time.clock()
while True:
    l = []
    (n, x) = list(map(int, input().split()))
    if n == x == 0:
        break
    ans = 0
    for a in range(1, n + 1):
        l.append(a)
    for i in l:
        if i > 98:
            break
        for j in l:
            if j > 99 or i + j > x:
                break
            p = 0
            for k in l:
                p = i + j + k
                if (i != j and j != k and k != i) and p == x and i < j < k:
                    ans += 1
    print(ans)
# end = time.clock()
# print end - start

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)

-#!/usr/bin/env python -# -*- coding:utf-8 -*- -import timeit -import time -import sys -import io -import re -import math - -# start = time.time() -# start = time.clock() -while True: -    l = [] -    (n, x) = list(map(int, input().split())) -    if n == x == 0: +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: -    ans = 0 -    for a in range(1, n + 1): -        l.append(a) -    for i in l: -        if i > 98: -            break -        for j in l: -            if j > 99 or i + j > x: -                break -            p = 0 -            for k in l: -                p = i + j + k -                if (i != j and j != k and k != i) and p == x and i < j < k: -                    ans += 1 -# end = time.clock() -# print end - start