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

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

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

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

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

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	} main {

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	} ArrayList<Integer> listN = new ArrayList<Integer>(); listN new ArrayList<Integer>() ArrayList<Integer> listX = new ArrayList<Integer>(); listX new ArrayList<Integer>() int count = 0; count 0 while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		} true {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		} int n = input(); n input() input int x = input(); x input() input if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {

				break;

			} break; {

				listN.add(n);
				listX.add(x);

			} listN.add(n) listN.add listN n listX.add(x) listX.add listX x for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		} int i = 0; int i = 0; i 0 i < listN.size() i listN.size() listN.size listN i++ i++ i {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		} {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		} for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			} int j = 1; int j = 1; j 1 j <= listN.get(i) j listN.get(i) listN.get listN i j++ j++ j {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			} {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			} for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= listN.get(i) k listN.get(i) listN.get listN i k++ k++ k {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				} {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				} for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					} int l = k + 1; int l = k + 1; l k + 1 k 1 l <= listN.get(i) l listN.get(i) listN.get listN i l++ l++ l {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					} {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					} if (j + k + l == listX.get(i)) {

							count++;

						} j + k + l == listX.get(i) j + k + l j + k + l j k l listX.get(i) listX.get listX i {

							count++;

						} count++ count System.out.println(count) System.out.println System.out System System.out count count = 0 count 0 close() close String[] args args public static int input() {

		return scanner.nextInt();

	} input {

		return scanner.nextInt();

	} return scanner.nextInt(); scanner.nextInt() scanner.nextInt scanner public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	} close {

		if (scanner != null) {

			scanner.close();

		}
	} if (scanner != null) {

			scanner.close();

		} scanner != null scanner null {

			scanner.close();

		} scanner.close() scanner.close scanner public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

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

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> listN = new ArrayList<Integer>();
		ArrayList<Integer> listX = new ArrayList<Integer>();

		int count = 0;

		while (true) {

			int n = input();
			int x = input();

			if (n == 0 && x == 0) {

				break;

			} else {

				listN.add(n);
				listX.add(x);

			}
		}

		for (int i = 0; i < listN.size(); i++) {

			for (int j = 1; j <= listN.get(i); j++) {

				for (int k = j + 1; k <= listN.get(i); k++) {

					for (int l = k + 1; l <= listN.get(i); l++) {

						if (j + k + l == listX.get(i)) {

							count++;

						}
					}
				}
			}

			System.out.println(count);
			count = 0;

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}