import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) try {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} List<Integer> ret = new ArrayList<Integer>(); ret new ArrayList<Integer>() int n n x; x do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true); true {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} String[] inputList = br.readLine().split(" "); inputList br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " n = Integer.parseInt(inputList[0]) n Integer.parseInt(inputList[0]) Integer.parseInt Integer inputList[0] inputList 0 x = Integer.parseInt(inputList[1]) x Integer.parseInt(inputList[1]) Integer.parseInt Integer inputList[1] inputList 1 if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
					break;
				} break; {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				} if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					} x < 6 x 6 {
						ret.add(0);
					} ret.add(0) ret.add ret 0 {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					} List<int[]> hoge = new ArrayList<int[]>(); hoge new ArrayList<int[]>() int a a b b c; c for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						} a = 1; a = 1 a 1 a <= n a n a++ a++ a {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						} {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						} for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							} b = 1; b = 1 b 1 b <= n b n b++ b++ b {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							} {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							} for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								} c = 1; c = 1 c 1 c <= n c n c++ c++ c {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								} {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								} if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									} !(a == b || b == c || a == c) && a + b + c == x !(a == b || b == c || a == c) (a == b || b == c || a == c) a == b || b == c || a == c a == b a b b == c b c a == c a c a + b + c == x a + b + c a + b + c a b c x {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									} boolean flg = true; flg true for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										} int[] list hoge {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										} {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										} if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											} (list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c) (list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c) (list[0] == a || list[0] == b || list[0] == c) list[0] == a || list[0] == b || list[0] == c list[0] == a list[0] list 0 a list[0] == b list[0] list 0 b list[0] == c list[0] list 0 c (list[1] == a || list[1] == b || list[1] == c) list[1] == a || list[1] == b || list[1] == c list[1] == a list[1] list 1 a list[1] == b list[1] list 1 b list[1] == c list[1] list 1 c (list[2] == a || list[2] == b || list[2] == c) list[2] == a || list[2] == b || list[2] == c list[2] == a list[2] list 2 a list[2] == b list[2] list 2 b list[2] == c list[2] list 2 c {
												flg = false;
												break;
											} flg = false flg false break; if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										} flg {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										} int[] tmp = new int[3]; tmp new int[3] 3 tmp[0] = a tmp[0] tmp 0 a tmp[1] = b tmp[1] tmp 1 b tmp[2] = c tmp[2] tmp 2 c hoge.add(tmp) hoge.add hoge tmp break; ret.add(hoge.size()) ret.add ret hoge.size() hoge.size hoge for (int num : ret) {
				System.out.println(num);
			} int num ret {
				System.out.println(num);
			} {
				System.out.println(num);
			} System.out.println(num) System.out.println System.out System System.out num String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			int n, x;
			do {
				String[] inputList = br.readLine().split(" ");
				n = Integer.parseInt(inputList[0]);
				x = Integer.parseInt(inputList[1]);
				if (n == 0 && x == 0) {
					break;
				} else {
					if (x < 6) {
						ret.add(0);
					} else {
						List<int[]> hoge = new ArrayList<int[]>();
						int a, b, c;
						for (a = 1; a <= n; a++) {
							for (b = 1; b <= n; b++) {
								for (c = 1; c <= n; c++) {
									if (!(a == b || b == c || a == c) && a + b + c == x) {
										boolean flg = true;
										for (int[] list : hoge) {
											if ((list[0] == a || list[0] == b || list[0] == c)
													&& (list[1] == a || list[1] == b || list[1] == c)
													&& (list[2] == a || list[2] == b || list[2] == c)) {
												flg = false;
												break;
											}
										}
										if (flg) {
											int[] tmp = new int[3];
											tmp[0] = a;
											tmp[1] = b;
											tmp[2] = c;
											hoge.add(tmp);
											break;
										}
									}
								}
							}
						}
						ret.add(hoge.size());
					}
				}
			} while (true);
			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}