Problem:
How many ways?

Write a program which identifies the number of combinations of three integers which satisfy the following conditions:

You should select three distinct integers from 1 to n.

A total sum of the three integers is x.

For example, there are two combinations for n = 5 and x = 9.

1 + 3 + 5 = 9

2 + 3 + 4 = 9

Input

The input consists of multiple datasets. For each dataset, two integers n and x are given in a line.

The input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.

Constraints

3 ≤ n ≤ 100

0 ≤ x ≤ 300

Output

For each dataset, print the number of combinations in a line.

Sample Input

5 9
0 0

Sample Output

2

Note

      解説

Solution in C# (judge verdict: Accepted)

using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;

namespace Sweet
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 a,b;

            for(;;){
                string str = Console.ReadLine();

                b = str.IndexOf(" ");
                a = int.Parse(str.Substring(0, b));
                b = int.Parse(str.Substring(b));
                if (a == 0 && b == 0)
                    return;

                //Console.WriteLine("you entered {0} 0x{0:x4}.", num);
                //string ans = string.Format("{0}", num * num * num);
                Console.WriteLine("{0}", Sweep(a, b));
                /*Console.WriteLine("Hello World");*/
                //Console.ReadLine();
            }
        }
        private static int MaxSweep(int a, int b,int c)
        {
            if (a + c <= b)
                return a;
            else
            if (b + c <= a)
                return b;
            else
            {
                c = (a < b)?b-a:a-b;
                if (a <= b)
                    return b - c;
                else
                    return a - c;
            }
        }
        private static int Sweep(int a, int b)
        {
            int i,j,k,s,res=0;

            for (res = 0, i = MaxSweep(b, a, 3); 2 < i; i--)
                for (j = MaxSweep(i-1, b - i - 1, 2), s = b - i; 1 < j; j--)
                    for (k = MaxSweep(j-1, b - i - j, 1); s <= j + k && 0 < k; k--)
                    {
                        //Console.Write("{0}, {1}, {2} ", i, j, k);
                        if (s == j + k)
                        {
                            //Console.Write("{0}, {1}, {2} ", i, j, k);
                            res++;
                        }
                    }
            return res;
        }
    }
}