import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	}
} Main public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	} main {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<String> klist = new ArrayList<String>(); klist new ArrayList<String>() while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		} true {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc klist.add(line) klist.add klist line if (line.equals("0 0")) {
				break;
			} line.equals("0 0") line.equals line "0 0" {
				break;
			} break; for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		} String string klist {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		} {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		} if (string.equals("0 0")) {
				break;
			} string.equals("0 0") string.equals string "0 0" {
				break;
			} break; String[] k = string.split(" "); k string.split(" ") string.split string " " int[] v = new int[2]; v new int[2] 2 v[0] = Integer.parseInt(k[0]) v[0] v 0 Integer.parseInt(k[0]) Integer.parseInt Integer k[0] k 0 v[1] = Integer.parseInt(k[1]) v[1] v 1 Integer.parseInt(k[1]) Integer.parseInt Integer k[1] k 1 int count = 0; count 0 for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				}
			} int i = 1; int i = 1; i 1 i <= v[0] - 2 i v[0] - 2 v[0] v 0 2 i++ i++ i {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				}
			} {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				}
			} for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= v[0] - 1 j v[0] - 1 v[0] v 0 1 j++ j++ j {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				} {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					}
				} for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					} int j2 = j + 1; int j2 = j + 1; j2 j + 1 j 1 j2 <= v[0] j2 v[0] v 0 j2++ j2++ j2 {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					} {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

					} int sum = i + j + j2; sum i + j + j2 i + j + j2 i j j2 if (sum == v[1]) {
							count++;
						} sum == v[1] sum v[1] v 1 {
							count++;
						} count++ count System.out.println(count) System.out.println System.out System System.out count String[] arges arges public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	}
} public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}

		}

		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int[] v = new int[2];
			v[0] = Integer.parseInt(k[0]);
			v[1] = Integer.parseInt(k[1]);

			int count = 0;
			for (int i = 1; i <= v[0] - 2; i++) {
				for (int j = i + 1; j <= v[0] - 1; j++) {
					for (int j2 = j + 1; j2 <= v[0]; j2++) {
						int sum = i + j + j2;
						if (sum == v[1]) {
							count++;
						}

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

		}

	}
}