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

/**
 * Lesson7B 1 から n までの数の中から、重複無しで３つの数を
 * 選びそれらの合計が x となる組み合わせ の数を求めるプログラム
 * 例えば、1 から * 5 までの数から３つを選んで
 * それらの合計が 9 となる組み合わせは、
 * ?1 + 3 + 5 = 9
 * ?2 + 3 + 4 = 9
 * の２通りがあります。
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
} 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 public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
} Main /**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	} main {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	} ArrayList<Integer> intAryAnswer = new ArrayList<Integer>(); intAryAnswer new ArrayList<Integer>() int intAnswerCount = 0; intAnswerCount 0 try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		} catch (IOException e) {
			System.out.println(e);
		} IOException e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		} NumberFormatException e {
			System.out.println("数字で入力して下さい");
		} System.out.println("数字で入力して下さい") System.out.println System.out System System.out "数字で入力して下さい" {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in)); insBR new BufferedReader(
					new InputStreamReader(System.in)) int intThird = 0; intThird 0 int intAnswer = 0; intAnswer 0 while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			} true {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			} String strLine = insBR.readLine(); strLine insBR.readLine() insBR.readLine insBR if(strLine.equals("0 0")) {
					break;
				} strLine.equals("0 0") strLine.equals strLine "0 0" {
					break;
				} break; String[] strAryLine = strLine.split(" "); strAryLine strLine.split(" ") strLine.split strLine " " int intN = Integer.parseInt(strAryLine[0]); intN Integer.parseInt(strAryLine[0]) Integer.parseInt Integer strAryLine[0] strAryLine 0 int intX = Integer.parseInt(strAryLine[1]); intX Integer.parseInt(strAryLine[1]) Integer.parseInt Integer strAryLine[1] strAryLine 1 for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				} int i = intN; int i = intN; i intN i > 0 i 0 i-- i-- i {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				} {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				} for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					} int j = i - 1; int j = i - 1; j i - 1 i 1 j > 0 j 0 j-- j-- j {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					} {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					} intThird = intX - i - j intThird intX - i - j intX - i - j intX i j if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						} intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j 0 < intThird intThird != j intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j intThird <= intN intThird intN intThird != i intThird i intThird != j intThird j 0 < intThird 0 intThird intThird < j intThird j {
							intAnswer++;
						} intAnswer++ intAnswer intAryAnswer.add(intAnswer) intAryAnswer.add intAryAnswer intAnswer intAnswer = 0 intAnswer 0 intAnswerCount++ intAnswerCount for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			} int i = 0; int i = 0; i 0 i < intAnswerCount i intAnswerCount i++ i++ i {
				System.out.println(intAryAnswer.get(i));
			} {
				System.out.println(intAryAnswer.get(i));
			} System.out.println(intAryAnswer.get(i)) System.out.println System.out System System.out intAryAnswer.get(i) intAryAnswer.get intAryAnswer i String[] args args public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
} public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Lesson7B 1 から n までの数の中から、重複無しで３つの数を
 * 選びそれらの合計が x となる組み合わせ の数を求めるプログラム
 * 例えば、1 から * 5 までの数から３つを選んで
 * それらの合計が 9 となる組み合わせは、
 * ?1 + 3 + 5 = 9
 * ?2 + 3 + 4 = 9
 * の２通りがあります。
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Integer> intAryAnswer = new ArrayList<Integer>();

		int intAnswerCount = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));

			//２つの値が決まった時、残りの3つ目を初期化
			int intThird = 0;

			int intAnswer = 0;

			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0 0")) {
					break;
				}
				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				//nの値
				int intN = Integer.parseInt(strAryLine[0]);

				//xの値
				int intX = Integer.parseInt(strAryLine[1]);

				//3
				//12 13 23
				//4
				//12 13 14 23 34

				for(int i = intN; i > 0 ; i--) {
					for(int j = i - 1; j > 0; j--) {
						intThird = intX - i - j;
						if(intThird <= intN &&
								intThird != i &&
								intThird != j &&
								0 < intThird &&
								intThird < j
								) {
							intAnswer++;
						}
					}
				}

				intAryAnswer.add(intAnswer);
				intAnswer = 0;
				intAnswerCount++;

			}

			//出力
//			int intsize = intAryAnswer.size();
			for(int i = 0; i < intAnswerCount; i++) {
				System.out.println(intAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch(NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}