import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	}
} import java.util.*; util.* java public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	}
} Main public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	} main {
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int x x n n count; count while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		} true {
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		} x = input.nextInt() x input.nextInt() input.nextInt input n = input.nextInt() n input.nextInt() input.nextInt input if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			} x == 0  && n == 0 x == 0 x 0 n == 0 n 0 break; {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			} count = 0 count 0 for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				} int i = 1; int i = 1; i 1 i < x i x i++ i++ i {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				} {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				} for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					} int k = i+1; int k = i+1; k i+1 i 1 k <= x k x k++ k++ k {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					} {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					} if (n - i - k > k && n - k - i <= x) {
							count++;
						} n - i - k > k && n - k - i <= x n - i - k > k n - i - k n - i - k n i k k n - k - i <= x n - k - i n - k - i n k i x {
							count++;
						} count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	}
} Main
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int x, n, count;
		while(true)
		{
			x = input.nextInt();
			n = input.nextInt();
			if(x == 0  && n == 0)
				break;
			else {
				count = 0;
				for (int i = 1; i < x; i++) {
					for (int k = i+1; k <= x; k++) {
						if (n - i - k > k && n - k - i <= x) {
							count++;
						}
					}
				}
				System.out.println(count);
			}
		}
	}
}