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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	}
} 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 import java.util.List; List java.util public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	}
} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) List<Integer> answer = new ArrayList<Integer>(); answer new ArrayList<Integer>() int count = 0 ; count 0 while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		} true {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		} String line = br.readLine(); line br.readLine() br.readLine br if ("0 0".equals(line)) {
				break;
			} "0 0".equals(line) "0 0".equals "0 0" line {
				break;
			} break; String[] inputData = line.split(" "); inputData line.split(" ") line.split line " " int n = Integer.parseInt(inputData[0]); n Integer.parseInt(inputData[0]) Integer.parseInt Integer inputData[0] inputData 0 int x = Integer.parseInt(inputData[1]); x Integer.parseInt(inputData[1]) Integer.parseInt Integer inputData[1] inputData 1 count = 0 count 0 for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			} int i =1; int i =1; i 1 i< n-1 && i < x i< n-1 i n-1 n 1 i < x i x i++ i++ i {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			} {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			} for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j < n && j < x j < n j n j < x j x j++ j++ j {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				} {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				} for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					} int k = j + 1; int k = j + 1; k j + 1 j 1 k < n + 1 && k < x k < n + 1 k n + 1 n 1 k < x k x 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 for(int output : answer) {
			System.out.println(output);
		} int output answer {
			System.out.println(output);
		} {
			System.out.println(output);
		} System.out.println(output) System.out.println System.out System System.out output String[] args args public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	}
} public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answer = new ArrayList<Integer>();
		int count = 0 ;
		while (true) {
			String line = br.readLine();
			if ("0 0".equals(line)) {
				break;
			}
			String[] inputData = line.split(" ");
			int n = Integer.parseInt(inputData[0]);
			int x = Integer.parseInt(inputData[1]);

			count = 0;
			for (int i =1; i< n-1 && i < x; i++) {
				for (int j = i + 1; j < n && j < x; j++) {
					for (int k = j + 1; k < n + 1 && k < x; k++) {
						if ((i + j + k) == x) {
							count++;
						}
					}
				}
			}
			answer.add(count);
		}

		for(int output : answer) {
			System.out.println(output);
		}
	}
}