import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		} true {
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if (n == 0 && x == 0)
			{
				return;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				return;
			} return; int ans = 0; ans 0 for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			} int a = 1; int a = 1; a 1 a <= n a n a++ a++ a {
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			} {
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			} for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				} int b = a + 1; int b = a + 1; b a + 1 a 1 b <= n b n b++ b++ b {
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				} {
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				} for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					} int c = b + 1; int c = b + 1; c b + 1 b 1 c <= n c n c++ c++ c {
						if (a + b + c == x)
						{
							ans++;
						}
					} {
						if (a + b + c == x)
						{
							ans++;
						}
					} if (a + b + c == x)
						{
							ans++;
						} a + b + c == x a + b + c a + b + c a b c x {
							ans++;
						} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	}
} Main
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			int x = sc.nextInt();

			if (n == 0 && x == 0)
			{
				return;
			}

			int ans = 0;

			for (int a = 1; a <= n; a++)
			{
				for (int b = a + 1; b <= n; b++)
				{
					for (int c = b + 1; c <= n; c++)
					{
						if (a + b + c == x)
						{
							ans++;
						}
					}
				}
			}

			System.out.println(ans);
		}
	}
}

