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: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        public static List<int> over = new List<int>();

        public static List<List<int>> over2D = new List<List<int>>();

        static void Main(string[] args)
        {

            List<int> countlist = new List<int>();

            while (true)
            {
                string[] Input = Console.ReadLine().Split(' ');

                int usenum = int.Parse(Input[0]);
                int asknum = int.Parse(Input[1]);

                if (usenum == 0 && asknum == 0) break;

                int result = 0;

                List<int> resultlist = new List<int>();

                for (int a = 1; a <= usenum; a++)
                {
                    for (int b = 1; b <= usenum; b++)
                    {
                        //????????°????????´??????????????????
                        if (a == b) continue;

                        for (int c = 1; c <= usenum; c++)
                        {
                            //????????°????????´??????????????????
                            if (b == c || a == c) continue;

                            result = a + b + c;

                            if (result == asknum)
                            {
                                if (DoubleCheck(a, b, c))
                                {
                                    resultlist.Add(result);

                                    //??????????????????
                                    over.Add(a);
                                    over.Add(b);
                                    over.Add(c);

                                    over2D.Add(over);
                                }

                                over = new List<int>();
                            }

                            
                        }
                    }
                }

                countlist.Add(resultlist.Count);
            }


            //????????????
            foreach(var result in countlist)
            {
                Console.WriteLine(result);
            }

        }


        private static bool DoubleCheck(int a, int b, int c)
        {
            foreach(List<int> result in over2D)
            {
                if(a == result[0] || a == result[1] || a == result[2])
                {
                    if(b == result[0] || b == result[1] || b == result[2])
                    {
                        if (c == result[0] || c == result[1] || c == result[2]) return false;

                    }

                }
            }

            return true;
        }

    }

}