import java.util.Scanner;

//20180509
//04

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    }
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    } main {
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		} scanner.hasNextLine() scanner.hasNextLine scanner {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		} int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 if(n + x == 0) {
				break;
			} n + x == 0 n + x n x 0 {
				break;
			} break; for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;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 i n i++ i++ i {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			} {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			} for(int j = i + 1;j <= n;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 j n 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 System.out.println(count) System.out.println System.out System System.out count scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    }
} public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    }
} Main
import java.util.Scanner;

//20180509
//04

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n + x == 0) {
				break;
			}

			for(int i = 1;i <= n;i++) {
				for(int j = i + 1;j <= n;j++) {
					for(int k = j + 1;k <= n;k++) {
						if(i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		scanner.close();
    }
}
