import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	}
}


	 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		} ; {
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		} {
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		} int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int 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; int a = 1; a 1 int b = 1; b 1 int c = 1; c 1 int t = 0; t 0 for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			} a = 1; a = 1 a 1 a <= n a n ++a ++a a {
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			} {
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			} for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				} b = 1; b = 1 b 1 b <= n b n ++b ++b b {
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				} {
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				} for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					} c = 1; c = 1 c 1 c <= n c n ++c ++c c {
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					} {
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					} if(c == b || c == b || b == a)
						break; c == b || c == b || b == a c == b || c == b || b == a c == b c b c == b c b b == a b a break; if(c > b || b > a)
						break; c > b || b > a c > b c b b > a b a break; if(c + b + a == x)
						++t; c + b + a == x c + b + a c + b + a c b a x ++t t System.out.println(t) System.out.println System.out System System.out t String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	}
} public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		int n = scan.nextInt();
		int x = scan.nextInt();
		if(n ==0 && x == 0)
			break;
		int a = 1;
		int b = 1;
		int c = 1;
		int t = 0;
		for(a = 1; a <= n; ++a){
			for(b = 1; b <= n; ++b){
				for(c = 1; c <= n; ++c){
					if(c == b || c == b || b == a)
						break;
					if(c > b || b > a)
						break;
					if(c + b + a == x)
						++t;
						
					}
				}
			}
		System.out.println(t);
		}
	}
}


	