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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		} true {
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		} String str = br.readLine(); str br.readLine() br.readLine br String[] s = str.split(" "); s str.split(" ") str.split str " " int limit = Integer.parseInt(s[0]); limit Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int num= Integer.parseInt(s[1]); num Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int count = 0; count 0 if((limit == 0)&&(num == 0)){
				break;
			} (limit == 0)&&(num == 0) (limit == 0) limit 0 (num == 0) num 0 {
				break;
			} break; for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			} int i = 3; int i = 3; i 3 i <= limit i limit i++ i++ i {
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			} {
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			} for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				} int j = 2; int j = 2; j 2 j <= i j i j++ j++ j {
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				} {
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				} for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					} int k = 1; int k = 1; k 1 k <= j k j k++ k++ k {
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					} {
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					} if((i == j)||(j == k)||(k == i)){
							continue;
						} (i == j)||(j == k)||(k == i) (i == j)||(j == k)||(k == i) (i == j) i j (j == k) j k (k == i) k i {
							continue;
						} continue; if((i + j + k)==num){
							count++;
						} (i + j + k)==num (i + j + k) i + j + k i j k num {
							count++;
						} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}