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

public class Main {

	public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {

	public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	}

} Main public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	} main {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	} int x = 0 x 0 n = 0; n 0 int count = 0; count 0 ArrayList<Integer> answer = new ArrayList<Integer>(); answer new ArrayList<Integer>() String tmpbox[] = new String[2]; tmpbox new String[2] 2 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		} true {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		} String str = br.readLine(); str br.readLine() br.readLine br tmpbox = str.split(" ") tmpbox str.split(" ") str.split str " " n = Integer.parseInt(tmpbox[0]) n Integer.parseInt(tmpbox[0]) Integer.parseInt Integer tmpbox[0] tmpbox 0 x = Integer.parseInt(tmpbox[1]) x Integer.parseInt(tmpbox[1]) Integer.parseInt Integer tmpbox[1] tmpbox 1 if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 { // x,n??±???0????????????
				break;
			} break; if(n < 3 || n > 100){
				System.exit(0);
			} n < 3 || n > 100 n < 3 n 3 n > 100 n 100 {
				System.exit(0);
			} System.exit(0) System.exit System 0 for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= n-2 i n-2 n 2 ++i ++i i {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			} {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			} for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				} int j = i+1; int j = i+1; j i+1 i 1 j <= n-1 j n-1 n 1 ++j ++j j {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				} {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				} for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					} int k = j+1; int k = j+1; k j+1 j 1 k <= n k n ++k ++k k {
						if  (i+j+k == x) {
							++count;
						}
					} {
						if  (i+j+k == x) {
							++count;
						}
					} if  (i+j+k == x) {
							++count;
						} i+j+k == x i+j+k i+j+k i j k x {
							++count;
						} ++count count answer.add(count) answer.add answer count count = 0 count 0 int answer_length = answer.size(); answer_length answer.size() answer.size answer for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		} int t = 0; int t = 0; t 0 t < answer_length t answer_length ++t ++t t {
			System.out.println(answer.get(t));
		} {
			System.out.println(answer.get(t));
		} System.out.println(answer.get(t)) System.out.println System.out System System.out answer.get(t) answer.get answer t String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		/**
		 * ?????°,???????????£?¨?
		 */
		int x = 0, n = 0; // ??\????????°
		int count = 0;
		ArrayList<Integer> answer = new ArrayList<Integer>();
		String tmpbox[] = new String[2];

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/**
		 * ??°????§£?????????
		 */
		while (true) {
			String str = br.readLine();
			tmpbox = str.split(" ");
			n = Integer.parseInt(tmpbox[0]);
			x = Integer.parseInt(tmpbox[1]);

			if (n == 0 && x == 0) { // x,n??±???0????????????
				break;
			}
			if(n < 3 || n > 100){
				System.exit(0);
			}

			for (int i = 1; i <= n-2; ++i) {
				for (int j = i+1; j <= n-1; ++j) {
					for (int k = j+1; k <= n; ++k) {
						if  (i+j+k == x) {
							++count;
						}
					}
				}
			}
			answer.add(count); // ???????????¢??¨????????????????????°????´???????
			count = 0;
		}
		int answer_length = answer.size();
		for(int t = 0; t < answer_length; ++t){
			System.out.println(answer.get(t));
		}
	}

}