import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		} int a = 1; int a = 1; a 1 a>0 a 0 a++ a++ a {
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		} {
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		} int n =scan.nextInt(); n scan.nextInt() scan.nextInt scan int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int H = 0; H 0 if(n == 0 && x == 0){
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; int k[] = new int[n]; k new int[n] n for(int b = 0;b<n;b++){
				k[b] = b+1;
			} int b = 0; int b = 0; b 0 b<n b n b++ b++ b {
				k[b] = b+1;
			} {
				k[b] = b+1;
			} k[b] = b+1 k[b] k b b+1 b 1 for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			} int c = 0; int c = 0; c 0 c<n-2 c n-2 n 2 c++ c++ c {
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			} {
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			} for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				} int d = 1; int d = 1; d 1 d+c<n d+c d c n d++ d++ d {
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				} {
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				} for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					} int e = 1; int e = 1; e 1 e+d+c<n e+d+c e+d+c e d c n e++ e++ e {
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					} {
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					} if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						} k[c] + k[d+c] + k[e+d+c] == x k[c] + k[d+c] + k[e+d+c] k[c] + k[d+c] + k[e+d+c] k[c] k c k[d+c] k d+c d c k[e+d+c] k e+d+c e+d+c e d c x {
							H++;
						} H++ H System.out.println(H) System.out.println System.out System System.out H String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	}

}