import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
}
} Main public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
} main {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
} true {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
} int n=scan.nextInt(); n scan.nextInt() scan.nextInt scan int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int sum=0 sum 0 count=0; count 0 for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			} {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			} for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				} int j=2; int j=2; j 2 j<=n j n j++ j++ j {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				} {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				} for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					} int k=3; int k=3; k 3 k<=n k n k++ k++ k {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					} {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					} if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						} i == j || j == k || i == k i == j || j == k || i == k i == j i j j == k j k i == k i k {
						} {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						} sum = i+j+k sum i+j+k i+j+k i j k if (sum == a && i<j && j<k) {
							count += 1;
						} sum == a && i<j && j<k sum == a && i<j && j<k sum == a sum a i<j i j j<k j k {
							count += 1;
						} count += 1 count 1 if(n==0 && a==0) {
				break;
			} n==0 && a==0 n==0 n 0 a==0 a 0 {
				break;
			} break; System.out.println(count) System.out.println System.out System System.out count scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
}
} public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
}
} Main
import java.util.Scanner;

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