import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    }
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    } main {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		} sc.hasNextInt() sc.hasNextInt sc {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int c = 0; c 0 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 < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i < n - 1 i n - 1 n 1 i++ i++ i {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			} {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			} for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= n j n j++ j++ j {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				} {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				} if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					} i + j < x i + j i j x {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					} if (x - i - j <= n && x - i - j > j) {
							c++;
						} x - i - j <= n && x - i - j > j x - i - j <= n x - i - j x - i - j x i j n x - i - j > j x - i - j x - i - j x i j j {
							c++;
						} c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    }
} public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int c = 0;
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i < n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (i + j < x) {
						if (x - i - j <= n && x - i - j > j) {
							c++;
						}
					}
				}
			}
			System.out.println(c);
		}
    }
}

