import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	}

	private static int findWays(int n, int x) {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	}

}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	}

	private static int findWays(int n, int x) {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	}

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

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	} main {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	} int[] f_w = new int[2]; f_w new int[2] 2 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true); true {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		} for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			} int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
				f_w[i] = sc.nextInt();
			} {
				f_w[i] = sc.nextInt();
			} f_w[i] = sc.nextInt() f_w[i] f_w i sc.nextInt() sc.nextInt sc if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			} f_w[0] == 0 && f_w[1] == 0 f_w[0] == 0 f_w[0] f_w 0 0 f_w[1] == 0 f_w[1] f_w 1 0 {
				break;
			} break; {
				 System.out.println(findWays(f_w[0], f_w[1]));
			} System.out.println(findWays(f_w[0], f_w[1])) System.out.println System.out System System.out findWays(f_w[0], f_w[1]) findWays f_w[0] f_w 0 f_w[1] f_w 1 sc.close() sc.close sc String[] args args private static int findWays(int n, int x) {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	} findWays {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	} int cnt = 0; cnt 0 for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		} {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		} for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= n j n j++ j++ j {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			} {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			} for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= n k n k++ k++ k {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				} {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				} if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					} i != j && j != k && k != i && i + j + k == x k != i i != j && j != k && k != i && i + j + k == x i != j i j j != k j k k != i k i i + j + k == x i + j + k i + j + k i j k x {
							cnt++;
					} cnt++ cnt return cnt; cnt int n n int x x public class Main {

	public static void main(String[] args) {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	}

	private static int findWays(int n, int x) {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	}

} public class Main {

	public static void main(String[] args) {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	}

	private static int findWays(int n, int x) {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] f_w = new int[2];
		Scanner sc = new Scanner(System.in);

		do {
			for (int i = 0; i < 2; i++) {
				f_w[i] = sc.nextInt();
			}

			if (f_w[0] == 0 && f_w[1] == 0) {
				break;
			} else {
				 System.out.println(findWays(f_w[0], f_w[1]));
			}
		}while(true);
		sc.close();


	}

	private static int findWays(int n, int x) {
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {

					if (i != j && j != k && k != i && i + j + k == x) {
							cnt++;
					}

				}
			}
		}

		return cnt;

	}

}

