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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> countArrayList = new ArrayList<Integer>();
		while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		}
		for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		}
	}
} 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 class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> countArrayList = new ArrayList<Integer>();
		while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		}
		for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> countArrayList = new ArrayList<Integer>();
		while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		}
		for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> countArrayList = new ArrayList<Integer>();
		while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		}
		for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) ArrayList<Integer> countArrayList = new ArrayList<Integer>(); countArrayList new ArrayList<Integer>() while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		} true {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		} Integer count = 0; count 0 String strNum = br.readLine(); strNum br.readLine() br.readLine br if ("0 0".equals(strNum)) {
				break;
			} "0 0".equals(strNum) "0 0".equals "0 0" strNum {
				break;
			} break; String[] strNumArrays = strNum.split(" "); strNumArrays strNum.split(" ") strNum.split strNum " " Integer sum = 0; sum 0 for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= Integer.parseInt(strNumArrays[0]) i Integer.parseInt(strNumArrays[0]) Integer.parseInt Integer strNumArrays[0] strNumArrays 0 i++ i++ i {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			} {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			} for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= Integer.parseInt(strNumArrays[0]) j Integer.parseInt(strNumArrays[0]) Integer.parseInt Integer strNumArrays[0] strNumArrays 0 j++ j++ j {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				} {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				} for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= Integer.parseInt(strNumArrays[0]) k Integer.parseInt(strNumArrays[0]) Integer.parseInt Integer strNumArrays[0] strNumArrays 0 k++ k++ k {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					} {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					} sum = i + j + k sum i + j + k i + j + k i j k if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						} sum == Integer.parseInt(strNumArrays[1]) sum Integer.parseInt(strNumArrays[1]) Integer.parseInt Integer strNumArrays[1] strNumArrays 1 {
							count++;
						} count++ count countArrayList.add(count) countArrayList.add countArrayList count for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		} int i = 0; int i = 0; i 0 i < countArrayList.size() i countArrayList.size() countArrayList.size countArrayList i++ i++ i {
			System.out.println(countArrayList.get(i));
		} {
			System.out.println(countArrayList.get(i));
		} System.out.println(countArrayList.get(i)) System.out.println System.out System System.out countArrayList.get(i) countArrayList.get countArrayList i String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> countArrayList = new ArrayList<Integer>();
		while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		}
		for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		}
	}
}