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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} 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) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String x = ""; x "" try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			} (x = in.readLine()).equals("0 0") == false (x = in.readLine()).equals("0 0") (x = in.readLine()).equals (x = in.readLine()) x in.readLine() in.readLine in "0 0" false {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			} String[] data = x.split(" "); data x.split(" ") x.split x " " int n = Integer.parseInt(data[0]); n Integer.parseInt(data[0]) Integer.parseInt Integer data[0] data 0 int sum = (Integer.parseInt(data[1]) - 3); sum (Integer.parseInt(data[1]) - 3) Integer.parseInt(data[1]) Integer.parseInt Integer data[1] data 1 3 int num = 0; num 0 for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				} {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				} for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					} int j = (i + 1); int j = (i + 1); j (i + 1) i 1 (i + j) < sum (i + j) i j sum j++ j++ j {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					} {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					} int k = sum - (i + j); k sum - (i + j) sum (i + j) i j if ((k > j) && (k < n)) num++; (k > j) && (k < n) (k > j) k j (k < n) k n num++ num System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			while ((x = in.readLine()).equals("0 0") == false) {
				String[] data = x.split(" ");
				int n = Integer.parseInt(data[0]);
				int sum = (Integer.parseInt(data[1]) - 3);
				
				int num = 0;
				for (int i = 0; i < n; i++) {
					for (int j = (i + 1); (i + j) < sum; j++) {
						int k = sum - (i + j);
						if ((k > j) && (k < n)) num++;
					}
				}
				
				System.out.println(num);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}