import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		} true {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int count = 0; count 0 int I I J J K; K if(n == 0 && x == 0) {
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			} int i = 1; int i = 1; i 1 i <= Math.min(x-3, n) i Math.min(x-3, n) Math.min Math x-3 x 3 n i++ i++ i {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			} {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			} for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				} int j = 1; int j = 1; j 1 j <= Math.min(x-3, n) j Math.min(x-3, n) Math.min Math x-3 x 3 n j++ j++ j {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				} {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				} int k = x - i - j; k x - i - j x - i - j x i j if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					} (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n) (i != j && i != k && j!= k) i != j && i != k && j!= k i != j i j i != k i k j!= k j k (k >= 1 && k <= n) k >= 1 k 1 k <= n k n {
						count++;
					} count++ count System.out.println(count/6) System.out.println System.out System System.out count/6 count 6 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	}
}

