import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	} main {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = 0; count 0 while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		} true {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		} count = 0 count 0 int num1 = sc.nextInt(); num1 sc.nextInt() sc.nextInt sc int num2 = sc.nextInt(); num2 sc.nextInt() sc.nextInt sc if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			} num1 == 0 && num2 == 0 num1 == 0 num1 0 num2 == 0 num2 0 {
				break;
			} break; {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			} for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				} int i = 1; int i = 1; i 1 i <= num1 i num1 i++ i++ i {
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				} {
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				} for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= num1 j num1 j++ j++ j {
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					} {
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					} for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						} int y = j + 1; int y = j + 1; y j + 1 j 1 y <= num1 y num1 y++ y++ y {
							if(i + j + y == num2) {
								count++;
							}
						} {
							if(i + j + y == num2) {
								count++;
							}
						} if(i + j + y == num2) {
								count++;
							} i + j + y == num2 i + j + y i + j + y i j y num2 {
								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) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	}
}