import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	}
} import java.io.*; io.* java public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		} true {
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		} String line = reader.readLine(); line reader.readLine() reader.readLine reader String[] str = line.split(" ", -1); str line.split(" ", -1) line.split line " " -1 1 int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int x = Integer.parseInt(str[1]); x Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(n == 0 && x == 0){
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; int count = 0; count 0 int a = 1; a 1 int b = 2; b 2 int c = 3; c 3 while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			} true {
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			} c = x - (a + b) c x - (a + b) x (a + b) a b if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				} c > n c n {
					b++;
				} b++ b {
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				} if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					} b >= c b c {
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					} a++ a if(a == n - 1){
							break;
						}else{
							b = a + 1;
						} a == n - 1 a n - 1 n 1 {
							break;
						} break; {
							b = a + 1;
						} b = a + 1 b a + 1 a 1 {
					count++;
					b++;
					} count++ count b++ b 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 reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	}
} Main
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			String[] str = line.split(" ", -1);
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			int a = 1;
			int b = 2;
			int c = 3;
			while(true){
				c = x - (a + b);
				if(c > n){
					b++;
				}else{
					if(b >= c){
						a++;
						if(a == n - 1){
							break;
						}else{
							b = a + 1;
						}
					}else{
					count++;
					b++;
					}
				}
			}
			System.out.println(count);
		}
	}
}