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

public class Main {

	public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	}

} Main public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	} main {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	} int addTrue; addTrue int Number; Number int Count = 0; Count 0 int[] NumList = new int[2]; NumList new int[2] 2 String[] InputList; InputList Scanner sc = null; sc null try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		} 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 {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			} true {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			} String line = br.readLine(); line br.readLine() br.readLine br if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				} line != null line null {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				} InputList = line.split(" ", 0) InputList line.split(" ", 0) line.split line " " 0 for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					} int i = 0; int i = 0; i 0 i < InputList.length i InputList.length InputList InputList.length i++ i++ i {
						NumList[i] = Integer.parseInt(InputList[i]);
					} {
						NumList[i] = Integer.parseInt(InputList[i]);
					} NumList[i] = Integer.parseInt(InputList[i]) NumList[i] NumList i Integer.parseInt(InputList[i]) Integer.parseInt Integer InputList[i] InputList i Number = NumList[0] Number NumList[0] NumList 0 addTrue = NumList[1] addTrue NumList[1] NumList 1 if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					} Number != 0 || addTrue != 0 Number != 0 Number 0 addTrue != 0 addTrue 0 {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					} Count = 0 Count 0 for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						} int i = 1; int i = 1; i 1 i <= Number i Number i++ i++ i {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						} {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						} for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= Number j Number j++ j++ j {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							} {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							} for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= Number k Number k++ k++ k {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								} {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								} if ((i + j + k) == addTrue) {
										Count++;
									} (i + j + k) == addTrue (i + j + k) i + j + k i j k addTrue {
										Count++;
									} Count++ Count System.out.println(Count) System.out.println System.out System System.out Count {
						break;
					} break; {
					break;
				} break; String[] args args public class Main {

	public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	}

} public class Main {

	public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	}

}