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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	}

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

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> lines = new ArrayList<String>(); lines new ArrayList<String>() int in = 0; in 0 while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		} true {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		} String string = sc.nextLine(); string sc.nextLine() sc.nextLine sc if (string.equals("0 0")) {
				break;
			} string.equals("0 0") string.equals string "0 0" {
				break;
			} break; lines.add(string) lines.add lines string in++ in for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		} int i = 0; int i = 0; i 0 i < in i in i++ i++ i {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		} {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		} int answer = 0; answer 0 String[] kari = lines.get(i).split(" "); kari lines.get(i).split(" ") lines.get(i).split lines.get(i) lines.get lines i " " int n = Integer.parseInt(kari[0]); n Integer.parseInt(kari[0]) Integer.parseInt Integer kari[0] kari 0 int x = Integer.parseInt(kari[1]); x Integer.parseInt(kari[1]) Integer.parseInt Integer kari[1] kari 1 for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			} int j = 1; int j = 1; j 1 j <= n - 2 j n - 2 n 2 j++ j++ j {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			} {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			} for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= n - 1 k n - 1 n 1 k++ k++ k {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				} {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				} for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					} int l = k + 1; int l = k + 1; l k + 1 k 1 l <= n l n l++ l++ l {
						if (j + k + l == x) {
							answer++;
						}
					} {
						if (j + k + l == x) {
							answer++;
						}
					} if (j + k + l == x) {
							answer++;
						} j + k + l == x j + k + l j + k + l j k l x {
							answer++;
						} answer++ answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	}

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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}
			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int answer = 0;
			String[] kari = lines.get(i).split(" ");
			int n = Integer.parseInt(kari[0]);
			int x = Integer.parseInt(kari[1]);

			for (int j = 1; j <= n - 2; j++) {
				for (int k = j + 1; k <= n - 1; k++) {
					for (int l = k + 1; l <= n; l++) {
						if (j + k + l == x) {
							answer++;
						}
					}

				}

			}
			
			System.out.println(answer);

		}
	}

}