import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	}
} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) ArrayList<Integer> number = new ArrayList<Integer>(); number new ArrayList<Integer>() int n = 0; n 0 int x = 0; x 0 int countA = 0; countA 0 while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		} true {
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		} n = scan.nextInt() n scan.nextInt() scan.nextInt scan x = scan.nextInt() x scan.nextInt() scan.nextInt scan int count = 0; count 0 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++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			} {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			} for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				} int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				} {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				} for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					} int k = 1; int k = 1; k 1 k <= n k n k++ k++ k {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					} {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					} if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						} i == j || j == k i == j i j j == k j k {
							continue;
						} continue; if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						} i < j && j < k i < j i j j < k j k {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						} int s = i + j + k; s i + j + k i + j + k i j k if (s == x) {
								count = count + 1;
							} s == x s x {
								count = count + 1;
							} count = count + 1 count count + 1 count 1 number.add(count) number.add number count countA++ countA for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		} int h = 0; int h = 0; h 0 h < countA h countA h++ h++ h {
			System.out.println(number.get(h));
		} {
			System.out.println(number.get(h));
		} System.out.println(number.get(h)) System.out.println System.out System System.out number.get(h) number.get number h String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> number = new ArrayList<Integer>();
		
		int n = 0;
		int x = 0;
		int countA = 0;
		
		while(true){
			n = scan.nextInt();
			x = scan.nextInt();
			int count = 0;
			if(n == 0 && x == 0){
				break;
			}
			
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					for (int k = 1; k <= n; k++) {
						if (i == j || j == k) {
							continue;
						} else if (i < j && j < k) {
							int s = i + j + k;
							if (s == x) {
								count = count + 1;
							}
						}
					}
				}
			}
			number.add(count);
			countA++;
		}
		for(int h = 0; h < countA; h++){
			System.out.println(number.get(h));
		}
	}
}