

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	}
} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	}
} Main public static void main(String[] args) {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	} main {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	} int all_number = 0; all_number 0 int answer = 0; answer 0 String out_all = ""; out_all "" Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		} sc.hasNext() sc.hasNext sc {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		} all_number = sc.nextInt() all_number sc.nextInt() sc.nextInt sc answer = sc.nextInt() answer sc.nextInt() sc.nextInt sc if (all_number == 0 && answer == 0)
				break; all_number == 0 && answer == 0 all_number == 0 all_number 0 answer == 0 answer 0 break; int out = 0; out 0 for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			} int f = 1; int f = 1; f 1 f <= all_number f all_number f++ f++ f {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			} {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			} for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				} int s = 1; int s = 1; s 1 s <= all_number s all_number s++ s++ s {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				} {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				} if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					} s != f s f {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					} for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						} int t = 1; int t = 1; t 1 t <= all_number t all_number t++ t++ t {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						} {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						} if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							} s != f && f != t && t != s && s + f + t == answer t != s s != f && f != t && t != s && s + f + t == answer s != f s f f != t f t t != s t s s + f + t == answer s + f + t s + f + t s f t answer {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							} out = 1 + out out 1 + out 1 out out = out / 6 out out / 6 out 6 out_all = out_all+""+String.valueOf(out)+"\n" out_all out_all+""+String.valueOf(out)+"\n" String.valueOf(out) out_all+""+String.valueOf(out)+"\n" out_all "" String.valueOf(out) String.valueOf String out "\n" System.out.print(out_all) System.out.print System.out System System.out out_all String[] args args public class Main{

	public static void main(String[] args) {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	}
} public class Main{

	public static void main(String[] args) {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	}
} Main


import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		//
		int all_number = 0;
		int answer = 0;
		String out_all = "";

		// テキスト入力クラス
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {
			//
			all_number = sc.nextInt();
			answer = sc.nextInt();

			if (all_number == 0 && answer == 0)
				break;
			int out = 0;
			// 一つ目の数を選ぶ
			for (int f = 1; f <= all_number; f++) {
				// 二つ目の数を選ぶ
				for (int s = 1; s <= all_number; s++) {
					// 同じ数字は使えないので
					if (s != f) {
						// 三つの数を選ぶ
						for (int t = 1; t <= all_number; t++) {
							if (s != f && f != t && t != s && s + f + t == answer) {
								//System.out.println(f+","+s+","+t);
								out = 1 + out;
							}
						}
					}
				}
			}
			// 組み合わせなので、3で割る
			out = out / 6;
			// 出力文字列
			out_all = out_all+""+String.valueOf(out)+"\n";
		}
		// 出力
		System.out.print(out_all);
	}
}