import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	}
	static int check(int m,int n){
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	}
	static int check(int m,int n){
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	} main {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n n x; x int y[][] = new int[50][2]; y new int[50][2] 50 2 int i = 0; i 0 while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		} true {
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		} n = stdIn.nextInt() n stdIn.nextInt() stdIn.nextInt stdIn x = stdIn.nextInt() x stdIn.nextInt() stdIn.nextInt stdIn if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			} (n==0)&&(x==0) (n==0) n 0 (x==0) x 0 {
				break;
			} break; {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			} y[i][0] = n y[i][0] y[i] y i 0 n y[i][1] = x y[i][1] y[i] y i 1 x i++ i stdIn.close() stdIn.close stdIn for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		} int j=0; int j=0; j 0 j<i j i j++ j++ j {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		} {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		} if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			} (y[j][0]*3-3 < y[j][1])|| y[j][1]<6 (y[j][0]*3-3 < y[j][1]) y[j][0]*3-3 y[j][0]*3 y[j][0] y[j] y j 0 3 3 y[j][1] y[j] y j 1 y[j][1]<6 y[j][1] y[j] y j 1 6 {
				System.out.println("0");
			} System.out.println("0") System.out.println System.out System System.out "0" if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			} (y[j][0] !=0) && (y[j][1]!=0) (y[j][0] !=0) y[j][0] y[j] y j 0 0 (y[j][1]!=0) y[j][1] y[j] y j 1 0 {
				System.out.println(check(y[j][0],y[j][1]));
			} System.out.println(check(y[j][0],y[j][1])) System.out.println System.out System System.out check(y[j][0],y[j][1]) check y[j][0] y[j] y j 0 y[j][1] y[j] y j 1 String[] args args static int check(int m,int n){
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	} check {
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	} int ans=0; ans 0 for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		} int a=m; int a=m; a m a>=1 a 1 a-- a-- a {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		} {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		} for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			} int b=m; int b=m; b m b>=1 b 1 b-- b-- b {
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			} {
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			} if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				} (1<=n-a-b) && (n-a-b <= m) (1<=n-a-b) 1 n-a-b n-a-b n a b (n-a-b <= m) n-a-b n-a-b n a b m {
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				} if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					} (a!=b) && (a!=n-a-b) && (b!=n-a-b) (a!=b) && (a!=n-a-b) && (b!=n-a-b) (a!=b) a b (a!=n-a-b) a n-a-b n-a-b n a b (b!=n-a-b) b n-a-b n-a-b n a b {
						ans +=1;
					} ans +=1 ans 1 return ans/6; ans/6 ans 6 int m m int n n public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	}
	static int check(int m,int n){
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	}
	static int check(int m,int n){
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n,x;
		int y[][] = new int[50][2];
		int i = 0;
		while(true){
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			if ((n==0)&&(x==0)) {
				break;
			} else {
				y[i][0] = n;
				y[i][1] = x;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			if((y[j][0]*3-3 < y[j][1])|| y[j][1]<6) {
				System.out.println("0");
			} else if((y[j][0] !=0) && (y[j][1]!=0)) {
				System.out.println(check(y[j][0],y[j][1]));
			}
		}
	}
	static int check(int m,int n){
		int ans=0;
		for(int a=m;a>=1;a--) {
			for(int b=m;b>=1;b--){
				if((1<=n-a-b) && (n-a-b <= m)){
					if((a!=b) && (a!=n-a-b) && (b!=n-a-b)) {
						ans +=1;
					}
				}

			}
		}

		return ans/6;
	}
}

