import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	}
} import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strargs; strargs int n n x x i i j j k k sum; sum do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true); true {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} sum = 0 sum 0 strargs = br.readLine().split("\\s+") strargs br.readLine().split("\\s+") br.readLine().split br.readLine() br.readLine br "\\s+" n = Integer.parseInt(strargs[0]) n Integer.parseInt(strargs[0]) Integer.parseInt Integer strargs[0] strargs 0 x = Integer.parseInt(strargs[1]) x Integer.parseInt(strargs[1]) Integer.parseInt Integer strargs[1] strargs 1 for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			} i = 1; i = 1 i 1 i <= n i n i++ i++ i {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			} {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			} for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				} j = i; j = i j i j <= n j n j++ j++ j {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				} {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				} for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					} k = j; k = j k j k <= n k n k++ k++ k {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					} {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					} if ((i + j + k) == x && i != j && j != k && i != k) sum++; (i + j + k) == x && i != j && j != k && i != k j != k (i + j + k) == x && i != j && j != k && i != k (i + j + k) == x (i + j + k) i + j + k i j k x i != j i j j != k j k i != k i k sum++ sum if (n == 0 && x ==0) break; n == 0 && x ==0 n == 0 n 0 x ==0 x 0 break; System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	}
} Main
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	}
}