import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	}

} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	}

} Main /**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		} true {
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		} String input = br.readLine(); input br.readLine() br.readLine br if(input.equals("0 0")){
				break;
			} input.equals("0 0") input.equals input "0 0" {
				break;
			} break; String[] numbers = input.split(" "); numbers input.split(" ") input.split input " " Integer max = Integer.parseInt(numbers[0]); max Integer.parseInt(numbers[0]) Integer.parseInt Integer numbers[0] numbers 0 Integer target = Integer.parseInt(numbers[1]); target Integer.parseInt(numbers[1]) Integer.parseInt Integer numbers[1] numbers 1 ArrayList<Integer[]> result = new ArrayList<Integer[]>(); result new ArrayList<Integer[]>() for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= max i max i++ i++ i {
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			} {
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			} for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				} int j = 1; int j = 1; j 1 j <= max j max j++ j++ j {
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				} {
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				} if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					} j != i j i {
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					} for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						} int k = 1; int k = 1; k 1 k <= max k max k++ k++ k {
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						} {
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						} if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							} k != i && k != j k != i k i k != j k j {
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							} if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								} i + j + k == target i + j + k i + j + k i j k target {
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								} Integer[] comb = {i, j, k}; comb {i, j, k} i j k Arrays.sort(comb) Arrays.sort Arrays comb boolean is_contain = false; is_contain false for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									} int l = 0; int l = 0; l 0 l< result.size() l result.size() result.size result l++ l++ l {
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									} {
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									} if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										} result.size() > 0 && Arrays.equals(result.get(l), comb) result.size() > 0 result.size() result.size result 0 Arrays.equals(result.get(l), comb) Arrays.equals Arrays result.get(l) result.get result l comb {
											is_contain = true;
										} is_contain = true is_contain true if(!is_contain){
										result.add(comb);
									} !is_contain is_contain {
										result.add(comb);
									} result.add(comb) result.add result comb System.out.println(result.size()) System.out.println System.out System System.out result.size() result.size result String[] args args public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	}

} public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	}

} Main
import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			if(input.equals("0 0")){
				break;
			}
			String[] numbers = input.split(" ");
			Integer max = Integer.parseInt(numbers[0]);
			Integer target = Integer.parseInt(numbers[1]);
			ArrayList<Integer[]> result = new ArrayList<Integer[]>();
			for(int i = 1; i <= max; i++){
				for(int j = 1; j <= max; j++){
					if(j != i){
						for(int k = 1; k <= max; k++){
							if(k != i && k != j){
								if(i + j + k == target){
									Integer[] comb = {i, j, k};
									Arrays.sort(comb);
									boolean is_contain = false;
									for(int l = 0; l< result.size(); l++){
										if(result.size() > 0 && Arrays.equals(result.get(l), comb)){
											is_contain = true;
										}
									}
									if(!is_contain){
										result.add(comb);
									}
								}
							}
						}
					}
				}
			}
			System.out.println(result.size());
		}
	}

}