import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	}
} Main public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	} main {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int sum sum count = 0; count 0 int n n x; x boolean flg = true; flg true while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		} true {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		} n = scan.nextInt() n scan.nextInt() scan.nextInt scan x = scan.nextInt() x scan.nextInt() scan.nextInt scan if(n == 0 && x == 0)break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; count = 0 count 0 for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			} {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			} sum = i sum i for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				} int j = 1 + i; int j = 1 + i; j 1 + i 1 i j <= n j n j++ j++ j {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				} {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				} sum = i sum i if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					} j != i j i {
						sum += j;
						flg = true;
					} sum += j sum j flg = true flg true {
						flg = false;
					} flg = false flg false for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					} int k = 1 + j; int k = 1 + j; k 1 + j 1 j k <= n k n k++ k++ k {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					} {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					} if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						} flg == true flg true {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						} sum = i + j sum i + j i j if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							} i != j && i != k && j != k i != j && i != k && j != k i != j i j i != k i k j != k j k {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							} sum += k sum k if( x == sum) {
									count++;
								} x == sum x sum {
									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 scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	}
} public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	}
}
