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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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 Integer count = 0; count 0 String result_size = ""; result_size "" for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= max i max i++ i++ i {
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			} {
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			} for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= max j max j++ j++ j {
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				} {
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				} for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= max k max k++ k++ k {
						if(i + j + k == target){
							count += 1;
						}
					} {
						if(i + j + k == target){
							count += 1;
						}
					} if(i + j + k == target){
							count += 1;
						} i + j + k == target i + j + k i + j + k i j k target {
							count += 1;
						} count += 1 count 1 result_size = result_size + count + "\n" result_size result_size + count + "\n" result_size + count + "\n" result_size count "\n" System.out.print(result_size) System.out.print System.out System System.out result_size 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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(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]);
			Integer count = 0;
			String result_size = "";
			for(int i = 1; i <= max; i++){
				for(int j = i + 1; j <= max; j++){
					for(int k = j + 1; k <= max; k++){
						if(i + j + k == target){
							count += 1;
						}
					}
				}
			}
			result_size = result_size + count + "\n" ;
			System.out.print(result_size);
		}
	}
}