import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) int n n x x ways; ways while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		} true {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		} ways = 0 ways 0 String[] num = in.readLine().split(" "); num in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " n = Integer.parseInt(num[0]) n Integer.parseInt(num[0]) Integer.parseInt Integer num[0] num 0 x = Integer.parseInt(num[1]) x Integer.parseInt(num[1]) Integer.parseInt Integer num[1] num 1 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; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= n i n i += 1 i += 1 i 1 {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			} {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			} for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				} int j = 1; int j = 1; j 1 j <= n j n j += 1 j += 1 j 1 {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				} {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				} for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					} int k = 1; int k = 1; k 1 k <= n k n k += 1 k += 1 k 1 {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					} {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					} if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						} i == j || j == k || i == k i == j || j == k || i == k i == j i j j == k j k i == k i k {
							continue;
						} continue; if (i + j + k == x) {
							ways++;
						} i + j + k == x i + j + k i + j + k i j k x {
							ways++;
						} ways++ ways System.out.println(ways / 6) System.out.println System.out System System.out ways / 6 ways 6 String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n, x, ways;
		while (true) {
			ways = 0;
			String[] num = in.readLine().split(" ");
			n = Integer.parseInt(num[0]);
			x = Integer.parseInt(num[1]);
			if (n == 0 && x == 0) {
				break;
			}
			for (int i = 1; i <= n; i += 1) {
				for (int j = 1; j <= n; j += 1) {
					for (int k = 1; k <= n; k += 1) {
						if (i == j || j == k || i == k) {
							continue;
						} else if (i + j + k == x) {
							ways++;
						}
					}
				}
			}
			System.out.println(ways / 6);
		}
	}
}