import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

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

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		}
	} main {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) while (s.hasNextInt()) {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		} s.hasNextInt() s.hasNextInt s {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		} int n = s.nextInt(); n s.nextInt() s.nextInt s int x = s.nextInt(); x s.nextInt() s.nextInt s int c = 0; c 0 if (n == 0 && x == 0) return; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 return; for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= n i n ++i ++i i {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			} {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			} for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= n j n ++j ++j j {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				} {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				} for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					} int k = j + 1; int k = j + 1; k j + 1 j 1 k <= n k n ++k ++k k {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					} {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					} int sum = i + j + k; sum i + j + k i + j + k i j k if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						} sum == x sum x {
							c++;
						} c++ c if (sum > x) {
							break;
						} sum > x sum x {
							break;
						} break; 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) {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

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

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNextInt()) {
			int n = s.nextInt();
			int x = s.nextInt();
			int c = 0;
			if (n == 0 && x == 0) return;

			for (int i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						int sum = i + j + k;
						if (sum == x) {
							c++;
						} else if (sum > x) {
							break;
						}
					}
				}
			}
			System.out.println(c);
		}
	}
}