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[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			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[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		} true {
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		} String[] tmp = br.readLine().split(" "); tmp br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(tmp[0]); n Integer.parseInt(tmp[0]) Integer.parseInt Integer tmp[0] tmp 0 int x = Integer.parseInt(tmp[1]); x Integer.parseInt(tmp[1]) Integer.parseInt Integer tmp[1] tmp 1 if(n == 0 && x == 0){
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; int start = x / 3 + 1; start x / 3 + 1 x / 3 x 3 1 int count = 0; count 0 for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			} int i = start; int i = start; i start i <= n i n i++ i++ i {
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			} {
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			} for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				} int j = ((start << 1) - (i + 1)); int j = ((start << 1) - (i + 1)); j ((start << 1) - (i + 1)) (start << 1) start 1 (i + 1) i 1 j < i j i j++ j++ j {
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				} {
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				} for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					} int k = 1; int k = 1; k 1 k < j k j k++ k++ k {
						if((i + j + k) == x){
							count++;
							break;
						}
					} {
						if((i + j + k) == x){
							count++;
							break;
						}
					} if((i + j + k) == x){
							count++;
							break;
						} (i + j + k) == x (i + j + k) i + j + k i j k x {
							count++;
							break;
						} count++ count break; 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[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			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[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			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[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}